#! /bin/bash
#上传jdk-8u201-linux-x64.tar.gz到/opt下
yum install -y gzip
#准备jdk环境
cd /opt
java -version
if [ $? -eq 0 ]
then echo "你已经安装有jkd环境"
else
cd /opt
echo "请稍后,正在为你解压..."
gunzip jdk-8u201-linux-x64.tar.gz
tar -xvhf jdk-8u201-linux-x64.tar
cp -r /opt/jdk1.8.0_201/ /usr/local/jdk
echo 'export JAVA_HOME=/usr/local/jdk' >> /etc/profile
echo 'export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar' >> /etc/profile
echo 'export PATH=$PATH:$JAVA_HOME/bin' >> /etc/profile
source /etc/profile
fi
ln -s /usr/local/jdk/bin/java /usr/bin/java
#java -version 查看jdk安装版本