Linux rpm方式安装JDK

官方网站:https://www.oracle.com/java/technologies/javase-downloads.html

1、下载JDK

wget https://download.oracle.com/otn-pub/java/jdk/16.0.1+9/7147401fd7354114ac51ef3e1328291f/jdk-16.0.1_linux-x64_bin.rpm?AuthParam=1623159461_69c80a9f6fb63f17c1d3ec6edb4df56b

2、安装JDK

rpm -ivh jdk-16.0.1_linux-x64_bin.rpm

3、配置环境变量

vim /etc/profile

# 末尾追加以下内容
export JAVA_HOME=/usr/java/default
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

4、重新加载环境变量使配置生效

source /etc/profile

5、查看是否安装成功

java -version

发表评论