shell脚本安装jdk

1、shell脚本安装jdk

提前把jdk安装包放在 /usr/local 下

[root@bogon ~]# cat jdk.sh 
#!/bin/bash
cd /usr/local/ && tar xf jdk-8u171-linux-x64.tar.gz
cat >> /etc/profile << EOF
export JAVA_HOME=/usr/local/jdk1.8.0_171/
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar 
export PATH=$PATH:$JAVA_HOME/bin
EOF
source /etc/profile && java -version

./jdk.sh

 

posted @ 2018-11-25 20:42  effortsing  阅读(741)  评论(0编辑  收藏  举报