1、下载
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
2、解压
tar -zxvf jdk-8u212-linux-x64.tar.gz mkdir /usr/local/jdk/ mv jdk1.8.0_212 /usr/local/jdk/
3、设置环境变量
vim /etc/profile.d/java.sh
#set java env export JAVA_HOME=/usr/local/jdk/jdk1.8.0_212 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH
source /etc/profile
ln -s /usr/local/jdk/jdk1.8.0_212/bin/java /usr/sbin/java
4、验证安装
java -version