下载地址
https://www.oracle.com/java/technologies/downloads/
1)创建目录
mkdir -p /usr/local/java
2)解压至指定目录
tar zxvf ../jdk-8u77-linux-x64.tar.gz -C /usr/local/java
3)配置环境变量
在文件最后添加如下配置:
JAVA_HOME=/usr/local/java/jdk1.8.0_161
export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/
export PATH=$PATH:$JAVA_HOME/bin
4)重新加载配置文件
source /etc/profile
5)检查
java -version
java version “1.8.0_161”
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)