#1.下载jdk(jdk1.8)

wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie"  http://download.oracle.com/otn-pub/java/jdk/8u60-b27/jdk-8u60-linux-x64.tar.gz

#2.安装jdk

echo "正在创建/usr/lib/jvm/目录"
sudo mkdir /usr/lib/jvm/
echo "目录/usr/lib/jvm/创建成功"
 
echo "正在解压缩jdk-8u60-linux-x64.tar.gz"
tar -zxvf jdk-8u60-linux-x64.tar.gz
echo "解压缩成功"
echo `ls -l`
 
echo "正在将jdk1.8.0_60/目录复制到/usr/lib/jvm/jdk1.8.0_60/"
sudo cp -r jdk1.8.0_60/ /usr/lib/jvm/jdk1.8.0_60/
echo "复制成功"


 
#3.配置环境变量

echo "配置环境变量"
echo "export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_60/" >>/etc/profile
echo "export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib" >>/etc/profile
echo "export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOMR/bin" >>/etc/profile
source /etc/profile
echo "配置环境成功"


 
#4.测试是否安装成功
 

echo "测试是否安装成功"
java -version
echo "安装成功"
 
echo "清理临时文件"
rm -rf jdk1.8.0_60/
echo "清理完成"

 

发表评论