1.检查系统是否自带有jdk
[root@test ~]# rpm -qa |grep java
[root@test ~]# rpm -qa |grep jdk
[root@test ~]# rpm -qa |grep gcj
如果有信息输出则需要卸载掉原来的jdk版本,用rpm -e … 例如: 卸载掉java
[root@test ~]# rpm -e java
2.yum查找Java 1.8+
[root@test ~]# yum list java-1.8*
Loaded plugins: fastestmirror, ovl
Available Packages
java-1.8.0-openjdk.x86_64 1:1.8.0.232.b09-1.el6_10
java-1.8.0-openjdk-debug.x86_64 1:1.8.0.232.b09-1.el6_10
java-1.8.0-openjdk-demo.x86_64 1:1.8.0.232.b09-1.el6_10
java-1.8.0-openjdk-demo-debug.x86_64 1:1.8.0.232.b09-1.el6_10
java-1.8.0-openjdk-devel.x86_64 1:1.8.0.232.b09-1.el6_10
java-1.8.0-openjdk-devel-debug.x86_64 1:1.8.0.232.b09-1.el6_10
java-1.8.0-openjdk-headless.x86_64 1:1.8.0.232.b09-1.el6_10
java-1.8.0-openjdk-headless-debug.x86_64 1:1.8.0.232.b09-1.el6_10
java-1.8.0-openjdk-javadoc.noarch 1:1.8.0.232.b09-1.el6_10
java-1.8.0-openjdk-javadoc-debug.noarch 1:1.8.0.232.b09-1.el6_10
java-1.8.0-openjdk-src.x86_64 1:1.8.0.232.b09-1.el6_10s
java-1.8.0-openjdk-src-debug.x86_64 1:1.8.0.232.b09-1.el6_10
3.安装jdk1.8.0的所有文件
yum install java-1.8.0-openjdk* -y
4.检查是否安装成功
[root@test ~]# java -version
openjdk version "1.8.0_232"
OpenJDK Runtime Environment (build 1.8.0_232-b09)
OpenJDK 64-Bit Server VM (build 25.232-b09, mixed mode)