到oracle官网下载二进制压缩文件
1.解压
2.编辑/etc/profile,添加以下配置
export JAVA_HOME=/opt/src/jdk1.8.0_171
export JRE_HOME=/opt/src/jdk1.8.0_171/jre
export PATH=$PATH:/opt/src/jdk1.8.0_171/bin
export CLASSPATH=./:/opt/src/jdk1.8.0_171/lib:/opt/src/jdk1.8.0_171/jre/lib
3.刷新配置
source /etc/profile
4.查看配置是否生效
java -version
5.出现以下信息就安装成功了
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)