热门IT资讯网

CentOS 7.7两种方式安装配置JDK 11 LTS

发表于:2024-11-21 作者:热门IT资讯网编辑
编辑最后更新 2024年11月21日,1、下载JDK 11 LTS:https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html

1、下载JDK 11 LTShttps://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

0