- 上传JDK
mkdir /applications
cd /applications
rz // 选择 jdk-8u172-linux-x64.tar.gz
- 解压缩并创建软连接
tar xf jdk-8u172-linux-x64.tar.gz -C /applications/
ln -s /applications/jdk1.8.0_172 /applications/jdk8
- 配置环境变量
vi /etc/profile
export JAVA_HOME=/applications/jdk8
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/li/tools.jar:
$JRE_HOME/lib/rt.jar
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
source /etc/profile
java -version
sed -i.ori '$a export JAVA_HOME=/applications/jdk8\nexport PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH\nexport CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar' /etc/profile
source /etc/profile
java -version