安装JDK

yum install java-1.8.0-openjdk* -y

安装成功

centos安装open-jdk8_yum安装

设置环境变量

centos 通过yum安装Java后,查看Java安装路径

ls -lrt /usr/bin/java 
ls -lrt /etc/alternatives/java

centos安装open-jdk8_jar_02

centos安装open-jdk8_java_03

vi /etc/profile

centos安装open-jdk8_jdk8_04

在文件最下方粘贴以下内容后保存

注意:JAVA_HOME后面,是你实际的安装路径!

export JAVA_HOME=/usr/lib/jvm/jdk-xxxx/
export JRE_HOME=/usr/lib/jvm/jdk-xxxx/jre
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$PATH

centos安装open-jdk8_jar_05

生效命令:source /etc/profile 
测试命令:java -version

centos安装open-jdk8_open-jdk8_06