安装方法

CentOS8上使用 yum 直接安装,环境变量自动配置好

查看是否已安装

看到下面结果,说明已经安装配置 jdk

[root@xxx ~]# java -version
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-b10)
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)

卸载

查看系统是否自带 jdk

rpm -qa |grep java
rpm -qa |grep jdk
rpm -qa |grep gcj

如果有输出信息,批量卸载系统自带

rpm -qa | grep java | xargs rpm -e --nodeps

如果使用 yum 安装的 jdk,请使用下面命令卸载

查看jdk1.8最新版本

yum install java-1.8.0-openjdk* -y

可以看到如下输出

[root@xxx ~]# yum list java-1.8*
Last metadata expiration check: 0:02:27 ago on Wed 26 Feb 2020 12:55:51 PM CST.
Available Packages
java-1.8.0-openjdk.x86_64                                                                                                 1:1.8.0.242.b08-0.el8_1                                                                                   AppStream
java-1.8.0-openjdk-accessibility.x86_64                                                                                   1:1.8.0.242.b08-0.el8_1                                                                                   AppStream
java-1.8.0-openjdk-demo.x86_64                                                                                            1:1.8.0.242.b08-0.el8_1                                                                                   AppStream
java-1.8.0-openjdk-devel.x86_64                                                                                           1:1.8.0.242.b08-0.el8_1                                                                                   AppStream
java-1.8.0-openjdk-headless.x86_64                                                                                        1:1.8.0.242.b08-0.el8_1                                                                                   AppStream
java-1.8.0-openjdk-javadoc.noarch                                                                                         1:1.8.0.242.b08-0.el8_1                                                                                   AppStream
java-1.8.0-openjdk-javadoc-zip.noarch                                                                                     1:1.8.0.242.b08-0.el8_1                                                                                   AppStream
java-1.8.0-openjdk-src.x86_64   

安装jdk1.8

yum install java-1.8.0-openjdk* -y

查看当前jdk版本

java -version

 

转载于:https://www.cnblogs.com/wandoupeas/p/centos_jdk_install.html