JDK安装
-
检查是否已经安装 JDK
使用以下命令检查是否已经安装 JDK,若已经安装 JDK,则不需要重新安装。
yum list installed | grep java
若已经安装,则出现以下的显示:
java-1.8.0-openjdk.x86_64 1:1.8.0.302.b08-0.el8_4 @AppStream
java-1.8.0-openjdk-accessibility.x86_64 1:1.8.0.302.b08-0.el8_4 @AppStream
java-1.8.0-openjdk-demo.x86_64 1:1.8.0.302.b08-0.el8_4 @AppStream
java-1.8.0-openjdk-devel.x86_64 1:1.8.0.302.b08-0.el8_4 @AppStream
java-1.8.0-openjdk-headless.x86_64 1:1.8.0.302.b08-0.el8_4 @AppStream
java-1.8.0-openjdk-headless-slowdebug.x86_64 1:1.8.0.302.b08-0.el8_4 @AppStream
java-1.8.0-openjdk-javadoc.noarch 1:1.8.0.302.b08-0.el8_4 @AppStream
java-1.8.0-openjdk-javadoc-zip.noarch 1:1.8.0.302.b08-0.el8_4 @AppStream
java-1.8.0-openjdk-slowdebug.x86_64 1:1.8.0.302.b08-0.el8_4 @AppStream
java-1.8.0-openjdk-src.x86_64 1:1.8.0.302.b08-0.el8_4 @AppStream
java-atk-wrapper.x86_64 0.33.2-6.el8 @AppStream
javapackages-filesystem.noarch 5.3.0-1.module_el8.0.0+11+5b8c10bd @AppStream
tzdata-java.noarch 2021a-1.el8 @AppStream
若未安装 **JDK** ,进行下面的步骤。
- 安装JDK
查看JDK软件包列表:
yum search java | grep -i jdk
显示以下:
java-11-openjdk.x86_64 : OpenJDK 11 Runtime Environment
java-11-openjdk.x86_64 : OpenJDK 11 Runtime Environment
java-1.8.0-openjdk.x86_64 : OpenJDK 8 Runtime Environment
java-1.8.0-openjdk.x86_64 : OpenJDK 8 Runtime Environment
java-11-openjdk-src.x86_64 : OpenJDK 11 Source Bundle
java-latest-openjdk.x86_64 : OpenJDK 16 Runtime Environment
java-11-openjdk-demo.x86_64 : OpenJDK 11 Demos
java-11-openjdk-devel.x86_64 : OpenJDK 11 Development Environment
java-11-openjdk-devel.x86_64 : OpenJDK 11 Development Environment
java-11-openjdk-jmods.x86_64 : JMods for OpenJDK 11
java-1.8.0-openjdk-src.x86_64 : OpenJDK 8 Source Bundle
java-1.8.0-openjdk-src.x86_64 : OpenJDK 8 Source Bundle
java-1.8.0-openjdk-demo.x86_64 : OpenJDK 8 Demos
java-1.8.0-openjdk-demo.x86_64 : OpenJDK 8 Demos
java-11-openjdk-javadoc.x86_64 : OpenJDK 11 API documentation
java-latest-openjdk-src.x86_64 : OpenJDK 16 Source Bundle
java-1.8.0-openjdk-devel.x86_64 : OpenJDK 8 Development Environment
java-11-openjdk-headless.x86_64 : OpenJDK 11 Headless Runtime Environment
java-1.8.0-openjdk-devel.x86_64 : OpenJDK 8 Development Environment
java-11-openjdk-headless.x86_64 : OpenJDK 11 Headless Runtime Environment
java-latest-openjdk-demo.x86_64 : OpenJDK 16 Demos
java-latest-openjdk-devel.x86_64 : OpenJDK 16 Development Environment
java-latest-openjdk-jmods.x86_64 : JMods for OpenJDK 16
java-1.8.0-openjdk-javadoc.noarch : OpenJDK 8 API documentation
java-1.8.0-openjdk-javadoc.noarch : OpenJDK 8 API documentation
选择版本进行安装:
#使用以下命令,安装jdk 1.8.0 的所有文件
yum install -y java-1.8.0-openjdk*
查看JDK是否安装成功
java -version
显示如下则表示安装成功:
[root@iZ2ze462m6o0ncl5uigv8hZ ~]# java -version
openjdk version "1.8.0_302"
OpenJDK Runtime Environment (build 1.8.0_302-b08)
OpenJDK 64-Bit Server VM (build 25.302-b08, mixed mode)
配置JDK环境变量