Java_sdk安装
自动化安装脚本如下,官网下载好Java sdk包后,配置好存放路径和安装路径,执行即可。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| #!/bin/bash # Java sdk包存放路径 java_addr=""
# Java sdk的安装路径 java_home=""
# 创建安装目录 mkdir -p $java_home if [ "$?" != "0" ]; then echo 'create file failed!' exit 1 fi
# 解压安装包 tar -zxvf $java_addr $java_home if [ "$?" != "0" ]; then echo 'decompression file failed!' exit 1 fi
# 配置Java环境变量 name=$(ls $java_home | grep jdk) echo "export JAVA_HOME=${java_home}/${name}" >> /etc/profile echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile echo 'export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar' >> /etc/profile if [ "$?" != "0" ]; then echo 'decompression file failed!' exit 1 fi
source /etc/profile
echo 'install successful!'
|