1.备份已存在的JDK
mv /usr/java /usr/java_bak
mkdir /usr/java
ll /usr/java
cd /usr/java
java -version
2.上传安装包
cp /root/jdk-8u231-linux-x64.tar.gz /usr/java/
ll
chmod 755 jdk-8u231-linux-x64.tar.gz
tar xvf jdk-8u231-linux-x64.tar.gz
ll
rm -f jdk-8u231-linux-x64.tar.gz
3.配置临时环境变量
vim /etc/profile.d/java.sh
cat /etc/profile.d/java.sh
export JAVA_HOME="/usr/java/jdk1.8.0_231"
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$JAVA_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
export JAVA_HOME="/usr/java/default"
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$JAVA_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
4.验证
yum install glibc.i686
source /etc/profile.d/java.sh
java -version
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
Java HotSpot(TM) Server VM (build 25.291-b10, mixed mode)
5.升级配置JDK环境
cd /usr/java/
rm -rf default latest jdk1.8.0_181-cloudera
ll
total 0
drwxr-xr-x 8 10143 10143 273 Apr 8 2021 jdk1.8.0_291
ln -sv jdk1.8.0_231 latest
ln -sv latest default