#!/bin/bash ######################################## #### 脚本结束执行source /etc/profile ######################################## baseDir=`dirname $0` localDir=`cd ${baseDir} && pwd` remoteFile=https://repo.huaweicloud.com/java/jdk/8u192-b12/jdk-8u192-linux-x64.tar.gz localFile=`echo ${remoteFile} |awk -F / ‘{print $NF}‘` curl -s -O ${remoteFile} trap "rm -f ${localDir}/${localFile}" EXIT tar -xzvf ${localFile} jdkDir=`ls -l |grep ^d.*jdk | awk ‘{print $NF}‘` javaHome=${localDir}/${jdkDir} echo export JAVA_HOME=${javaHome} >> /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 exit 0