1. 下载jdk : jdk-8u211-linux-x64.tar.gz
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
2.解压
tar -zxvf jdk-8u211-linux-x64.tar.gz
sudo mv jdk1.8.0_211 /opt/
4、配置环境 sudo vi /etc/profile,在最后添加
export JAVA_HOME=/opt/jdk1.8.0_211
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
5、生效配置 运行:source /etc/profile ,然后java -version 查看
[smile@MiWiFi-R3-srv jdk1.8.0_211]$ sudo vi /etc/profile [smile@MiWiFi-R3-srv jdk1.8.0_211]$ source /etc/profile [smile@MiWiFi-R3-srv jdk1.8.0_211]$ java -version java version "1.8.0_211" Java(TM) SE Runtime Environment (build 1.8.0_211-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode) [smile@MiWiFi-R3-srv jdk1.8.0_211]$
至此 OK