1、下载JDK 11 LTS:https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html
2、安装JDK 11 TLS:
# rpm -ivh jdk-11.0.6_linux-x64_bin.rpm
# java -version
或
# tar -xf jdk-11.0.6_linux-x64_bin.tar.gz -C /usr/local
# cd /usr/local
# mv jdk-11.0.6/ jdk
配置JDK环境变量:
# vim /etc/profile.d/jdk11.sh
export JAVA_HOME=/usr/local/jdk
export JRE_HOME=$JAVA_HOME
export CLASSPATH=.:$JAVA_HOME/lib
export PATH=$JAVA_HOME/bin:$PATH
# . /etc/profile.d/jdk11.sh
# java -version
3、多个JDK版本中选择JDK 11 LTS作为默认版本:
# alternatives --config java
备注:默认只有之前使用rpm包安装的JDK 8
# alternatives --install /usr/bin/java java /usr/local/jdk/bin/java 1
备注:alternatives [options] --install link name path priority
# alternatives --config java