1.获取java相关版本:yum -y list java*
2.下载需要的jdk:yum install java-1.8.0-openjdk.x86_64
3.编辑配置文件:vi /etc/profile
#set java environment
JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk.x86_64
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME CLASSPATH PATH
4.使配置生效:. /etc/profile
5.验证:java -version