1. 执行:yum install java-1.8.0-openjdk.x86_64
2. 设置jdk环境变量: vim /etc/profile
在文件最后加入如下配置:(点击i 进入编辑模式)
#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
3.保存退出:输入命令 :wq
4.修改profile文件后立即生效(注意: . 和 /etc/profile 有空格)
输入命令 . /etc/profile
5.查看java是否安装
输入命令 java -version