1)参考文章:
https://www.jianshu.com/p/848b06dd19aa
2)下载oracle的jdk
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
这里我的linux系统是64位
3)安装jdk
rpm -ivh jdk-8u151-linux-x64.rpm
4)配置环境变量:vim /etc/profile.d/java.sh
#!/bin/bash
export JAVA_HOME=/usr/java/jdk1.8.0_151/
export PATH=$JAVA_HOME/bin:$PATH
5)生效
chmod +x /etc/profile.d/java.sh
source /etc/profile.d/java.sh
查看java的版本:java -version