进入JDK下载页面:https://www.oracle.com/technetwork/java/javase/downloads/index.html
解压
tar -zxvf jdk-8u281-linux-x64.tar.gz
配置环境变量
vi /etc/profile
添加内容
export JAVA_HOME=/root/rj/jdk/jdk1.8.0_281 export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar export PATH=$PATH:${JAVA_HOME}/bin
重新加载配置文件
source /etc/profile
测试
[root@lcl-aliyun jdk1.8.0_281]# java -version java version "1.8.0_281" Java(TM) SE Runtime Environment (build 1.8.0_281-b09) Java HotSpot(TM) 64-Bit Server VM (build 25.281-b09, mixed mode)