(1) 查看Centos自带的Java环境yum list installed |grep java
(2)卸载现有Java环境 yum -y remove java-1.8.0-openjdk*yum -y remove tzdata-java*
(3)在yum库中查看Java安装包 yum -y list java*
![1637776455-ba45a868-44ef-4a4cacb5-5129bacb5-512.png]]
(4)安装JDK(无报错,即安装成功) yum -y install java-1.8.0-openjdk*
(5)查看Java安装的路径 which java
(6)添加Java环境变量 echo "export JAVA_HOME=/usr/lib/jvm/java-1.8.0 \ export JRE_HOME=$JAVA_HOME/jre \ export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin \ export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib \" >> /etc/profilesource /etc/profile
(7)检查Java安装配置 # 相应版本号的安装已成功安装java -version