liunx下通过yum安装jdk

1、先查看CentOs是否安装过jdk,并卸载

卸载:
rmp -e --allmathes --nodeps java-1.8.0-[openjdk](https://so.csdn.net/so/search?q=openjdk&spm=1001.2101.3001.7020)\-headless
再次查看:
rpm -[qa](https://so.csdn.net/so/search?q=qa&spm=1001.2101.3001.7020) | grep java

2、yum命令查找jdk 两种方法:

在根目录中查找

2.1 yum -y list java*

Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Installed Packages ==可安装的包
java-1.8.0-openjdk.x86_64 1:1.8.0.312.b07-1.el7_9 @updates
java-1.8.0-openjdk-headless.x86_64 1:1.8.0.312.b07-1.el7_9 @updates
javapackages-tools.noarch 3.4.1-11.el7 @os
Available Packages
java-1.6.0-openjdk.x86_64 1:1.6.0.41-1.13.13.1.el7_3 os
java-1.6.0-openjdk-demo.x86_64 1:1.6.0.41-1.13.13.1.el7_3 os
java-1.6.0-openjdk-devel.x86_64 1:1.6.0.41-1.13.13.1.el7_3 os
java-1.6.0-openjdk-javadoc.x86_64 1:1.6.0.41-1.13.13.1.el7_3 os
java-1.6.0-openjdk-src.x86_64 1:1.6.0.41-1.13.13.1.el7_3 os
java-1.7.0-openjdk.x86_64 1:1.7.0.261-2.6.22.2.el7_8 os
java-1.7.0-openjdk-accessibility.x86_64 1:1.7.0.261-2.6.22.2.el7_8 os
java-1.7.0-openjdk-demo.x86_64 1:1.7.0.261-2.6.22.2.el7_8 os
java-1.7.0-openjdk-devel.x86_64 1:1.7.0.261-2.6.22.2.el7_8 os
java-1.7.0-openjdk-headless.x86_64 1:1.7.0.261-2.6.22.2.el7_8 os
java-1.7.0-openjdk-javadoc.noarch 1:1.7.0.261-2.6.22.2.el7_8 os
java-1.7.0-openjdk-src.x86_64 1:1.7.0.261-2.6.22.2.el7_8 os
java-1.8.0-openjdk.i686 1:1.8.0.312.b07-1.el7_9 updates
java-1.8.0-openjdk-accessibility.i686 1:1.8.0.312.b07-1.el7_9 updates
java-1.8.0-openjdk-accessibility.x86_64 1:1.8.0.312.b07-1.el7_9 updates
java-1.8.0-openjdk-demo.i686 1:1.8.0.312.b07-1.el7_9 updates
java-1.8.0-openjdk-demo.x86_64 1:1.8.0.312.b07-1.el7_9 updates
java-1.8.0-openjdk-devel.i686 1:1.8.0.312.b07-1.el7_9 updates
java-1.8.0-openjdk-devel.x86_64 1:1.8.0.312.b07-1.el7_9 updates
java-1.8.0-openjdk-headless.i686 1:1.8.0.312.b07-1.el7_9 updates
java-1.8.0-openjdk-javadoc.noarch 1:1.8.0.312.b07-1.el7_9 updates
java-1.8.0-openjdk-javadoc-zip.noarch 1:1.8.0.312.b07-1.el7_9 updates
java-1.8.0-openjdk-src.i686 1:1.8.0.312.b07-1.el7_9 updates
java-1.8.0-openjdk-src.x86_64 1:1.8.0.312.b07-1.el7_9 updates
java-11-openjdk.i686 1:11.0.13.0.8-1.el7_9 updates
java-11-openjdk.x86_64 1:11.0.13.0.8-1.el7_9 updates
java-11-openjdk-demo.i686 1:11.0.13.0.8-1.el7_9 updates
java-11-openjdk-demo.x86_64 1:11.0.13.0.8-1.el7_9 updates
java-11-openjdk-devel.i686 1:11.0.13.0.8-1.el7_9 updates
java-11-openjdk-devel.x86_64 1:11.0.13.0.8-1.el7_9 updates
java-11-openjdk-headless.i686 1:11.0.13.0.8-1.el7_9 updates
java-11-openjdk-headless.x86_64 1:11.0.13.0.8-1.el7_9 updates
java-11-openjdk-javadoc.i686 1:11.0.13.0.8-1.el7_9 updates
java-11-openjdk-javadoc.x86_64 1:11.0.13.0.8-1.el7_9 updates
java-11-openjdk-javadoc-zip.i686 1:11.0.13.0.8-1.el7_9 updates
java-11-openjdk-javadoc-zip.x86_64 1:11.0.13.0.8-1.el7_9 updates
java-11-openjdk-jmods.i686 1:11.0.13.0.8-1.el7_9 updates
java-11-openjdk-jmods.x86_64 1:11.0.13.0.8-1.el7_9 updates
java-11-openjdk-src.i686 1:11.0.13.0.8-1.el7_9 updates
java-11-openjdk-src.x86_64 1:11.0.13.0.8-1.el7_9 updates
java-11-openjdk-static-libs.i686 1:11.0.13.0.8-1.el7_9 updates
java-11-openjdk-static-libs.x86_64 1:11.0.13.0.8-1.el7_9 updates
java-atk-wrapper.i686 0.30.4-5.el7 os
java-atk-wrapper.x86_64 0.30.4-5.el7 os
java-dirq.noarch 1.8-1.el7 epel
java-dirq-javadoc.noarch 1.8-1.el7 epel
java-latest-openjdk.x86_64 1:17.0.1.0.12-1.rolling.el7 epel
java-latest-openjdk-debug.x86_64 1:17.0.1.0.12-1.rolling.el7 epel
java-latest-openjdk-demo.x86_64 1:17.0.1.0.12-1.rolling.el7 epel
java-latest-openjdk-demo-debug.x86_64 1:17.0.1.0.12-1.rolling.el7 epel
java-latest-openjdk-demo-fastdebug.x86_64 1:17.0.1.0.12-1.rolling.el7 epel
java-latest-openjdk-devel.x86_64 1:17.0.1.0.12-1.rolling.el7 epel
java-latest-openjdk-devel-debug.x86_64 1:17.0.1.0.12-1.rolling.el7 epel
java-latest-openjdk-devel-fastdebug.x86_64 1:17.0.1.0.12-1.rolling.el7 epel java-latest-openjdk-fastdebug.x86_64 1:17.0.1.0.12-1.rolling.el7 epel
java-latest-openjdk-headless.x86_64 1:17.0.1.0.12-1.rolling.el7 epel
java-latest-openjdk-headless-debug.x86_64 1:17.0.1.0.12-1.rolling.el7 epel java-latest-openjdk-headless-fastdebug.x86_64 1:17.0.1.0.12-1.rolling.el7 epel
java-latest-openjdk-javadoc.x86_64 1:17.0.1.0.12-1.rolling.el7 epel
java-latest-openjdk-javadoc-zip.x86_64 1:17.0.1.0.12-1.rolling.el7 epel
java-latest-openjdk-jmods.x86_64 1:17.0.1.0.12-1.rolling.el7 epel
java-latest-openjdk-jmods-debug.x86_64 1:17.0.1.0.12-1.rolling.el7 epel
java-latest-openjdk-jmods-fastdebug.x86_64 1:17.0.1.0.12-1.rolling.el7 epel
java-latest-openjdk-src.x86_64 1:17.0.1.0.12-1.rolling.el7 epel
java-latest-openjdk-src-debug.x86_64 1:17.0.1.0.12-1.rolling.el7 epel
java-latest-openjdk-src-fastdebug.x86_64 1:17.0.1.0.12-1.rolling.el7 epel
java-latest-openjdk-static-libs.x86_64 1:17.0.1.0.12-1.rolling.el7 epel
java-latest-openjdk-static-libs-debug.x86_64 1:17.0.1.0.12-1.rolling.el7 epel
java-latest-openjdk-static-libs-fastdebug.x86_64 1:17.0.1.0.12-1.rolling.el7 epel java-oauth.noarch 20100601-13.el7 epel
java-oauth-javadoc.noarch 20100601-13.el7 epel
java-runtime-decompiler.noarch 5.1-1.el7 epel
java-runtime-decompiler-javadoc.noarch 5.1-1.el7 epel
java_cup.noarch 1:0.11a-16.el7 os
java_cup-javadoc.noarch 1:0.11a-16.el7 os
java_cup-manual.noarch 1:0.11a-16.el7 os
javacc.noarch 5.0-10.el7 os
javacc-demo.noarch 5.0-10.el7 os
javacc-javadoc.noarch 5.0-10.el7 os
javacc-manual.noarch 5.0-10.el7 os
javacc-maven-plugin.noarch 2.6-17.el7 os
javacc-maven-plugin-javadoc.noarch 2.6-17.el7 os
javamail.noarch 1.4.6-8.el7 os
javamail-javadoc.noarch 1.4.6-8.el7 os
javaparser.noarch 1.0.11-3.el7 epel
javaparser-javadoc.noarch 1.0.11-3.el7 epel
javassist.noarch 3.16.1-10.el7 os
javassist-javadoc.noarch 3.16.1-10.el7 os
javastroke.x86_64 0.5.1-33.el7 epel
javawriter.noarch 2.5.1-4.el7 epel
javawriter-javadoc.noarch 2.5.1-4.el7 epel

2.2 yum search jdk

Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
===================================================================================== N/S matched: jdk ======================================================================================
copy-jdk-configs.noarch : JDKs configuration files copier

========== jdk6============
java-1.6.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.6.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.6.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.6.0-openjdk-javadoc.x86_64 : OpenJDK API Documentation
java-1.6.0-openjdk-src.x86_64 : OpenJDK Source Bundle

========== jdk7============
java-1.7.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.7.0-openjdk-accessibility.x86_64 : OpenJDK accessibility connector
java-1.7.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.7.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.7.0-openjdk-headless.x86_64 : The OpenJDK runtime environment without audio and video support
java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundle

========== jdk8============
java-1.8.0-openjdk.i686 : OpenJDK Runtime Environment 8
java-1.8.0-openjdk.x86_64 : OpenJDK 8 Runtime Environment
java-1.8.0-openjdk-accessibility.i686 : OpenJDK accessibility connector
java-1.8.0-openjdk-accessibility.x86_64 : OpenJDK accessibility connector
java-1.8.0-openjdk-demo.i686 : OpenJDK Demos 8
java-1.8.0-openjdk-demo.x86_64 : OpenJDK 8 Demos
java-1.8.0-openjdk-devel.i686 : OpenJDK Development Environment 8
java-1.8.0-openjdk-devel.x86_64 : OpenJDK 8 Development Environment
java-1.8.0-openjdk-headless.i686 : OpenJDK Headless Runtime Environment 8
java-1.8.0-openjdk-headless.x86_64 : OpenJDK 8 Headless Runtime Environment
java-1.8.0-openjdk-javadoc.noarch : OpenJDK 8 API documentation
java-1.8.0-openjdk-javadoc-zip.noarch : OpenJDK 8 API documentation compressed in a single archive
java-1.8.0-openjdk-src.i686 : OpenJDK Source Bundle 8
java-1.8.0-openjdk-src.x86_64 : OpenJDK 8 Source Bundle

========== jdk11============
java-11-openjdk.i686 : OpenJDK Runtime Environment 11
java-11-openjdk.x86_64 : OpenJDK 11 Runtime Environment
java-11-openjdk-demo.i686 : OpenJDK Demos 11
java-11-openjdk-demo.x86_64 : OpenJDK 11 Demos
java-11-openjdk-devel.i686 : OpenJDK Development Environment 11
java-11-openjdk-devel.x86_64 : OpenJDK 11 Development Environment
java-11-openjdk-headless.i686 : OpenJDK Headless Runtime Environment 11
java-11-openjdk-headless.x86_64 : OpenJDK 11 Headless Runtime Environment
java-11-openjdk-javadoc.i686 : OpenJDK 11 API documentation
java-11-openjdk-javadoc.x86_64 : OpenJDK 11 API documentation
java-11-openjdk-javadoc-zip.i686 : OpenJDK 11 API documentation compressed in a single archive
java-11-openjdk-javadoc-zip.x86_64 : OpenJDK 11 API documentation compressed in a single archive
java-11-openjdk-jmods.i686 : JMods for OpenJDK 11
java-11-openjdk-jmods.x86_64 : JMods for OpenJDK 11
java-11-openjdk-src.i686 : OpenJDK Source Bundle 11
java-11-openjdk-src.x86_64 : OpenJDK 11 Source Bundle
java-11-openjdk-static-libs.i686 : OpenJDK libraries for static linking 11
java-11-openjdk-static-libs.x86_64 : OpenJDK 11 libraries for static linking
java-latest-openjdk.x86_64 : OpenJDK 17 Runtime Environment
java-latest-openjdk-debug.x86_64 : OpenJDK 17 Runtime Environment with full debugging on
java-latest-openjdk-demo.x86_64 : OpenJDK 17 Demos
java-latest-openjdk-demo-debug.x86_64 : OpenJDK 17 Demos with full debugging on
java-latest-openjdk-demo-fastdebug.x86_64 : OpenJDK 17 Demos with minimal debugging on
java-latest-openjdk-devel.x86_64 : OpenJDK 17 Development Environment
java-latest-openjdk-devel-debug.x86_64 : OpenJDK 17 Development Environment with full debugging on
java-latest-openjdk-devel-fastdebug.x86_64 : OpenJDK 17 Development Environment with minimal debugging on
java-latest-openjdk-fastdebug.x86_64 : OpenJDK 17 Runtime Environment with minimal debugging on
java-latest-openjdk-headless.x86_64 : OpenJDK 17 Headless Runtime Environment
java-latest-openjdk-headless-debug.x86_64 : OpenJDK 17 Runtime Environment with full debugging on
java-latest-openjdk-headless-fastdebug.x86_64 : OpenJDK 17 Runtime Environment with minimal debugging on
java-latest-openjdk-javadoc.x86_64 : OpenJDK 17 API documentation
java-latest-openjdk-javadoc-zip.x86_64 : OpenJDK 17 API documentation compressed in a single archive
java-latest-openjdk-jmods.x86_64 : JMods for OpenJDK 17
java-latest-openjdk-jmods-debug.x86_64 : JMods for OpenJDK 17 with full debugging on
java-latest-openjdk-jmods-fastdebug.x86_64 : JMods for OpenJDK 17 with minimal debugging on
java-latest-openjdk-src.x86_64 : OpenJDK 17 Source Bundle
java-latest-openjdk-src-debug.x86_64 : OpenJDK 17 Source Bundle for packages with debugging on
java-latest-openjdk-src-fastdebug.x86_64 : OpenJDK 17 Source Bundle %{for_fastdebug}
java-latest-openjdk-static-libs.x86_64 : OpenJDK 17 libraries for static linking
java-latest-openjdk-static-libs-debug.x86_64 : OpenJDK 17 libraries for static linking with full debugging on
java-latest-openjdk-static-libs-fastdebug.x86_64 : OpenJDK 17 libraries for static linking with minimal debugging on
ldapjdk-javadoc.noarch : Javadoc for ldapjdk
openjdk-asmtools-javadoc.noarch : Javadoc for openjdk-asmtools
icedtea-web.x86_64 : Additional Java components for OpenJDK - Java browser plug-in and Web Start implementation
ldapjdk.noarch : The Mozilla LDAP Java SDK
openjdk-asmtools.noarch : To develop tools create proper & improper Java ‘.class’ files
openprops.noarch : An improved java.util.Properties from OpenJDK

Name and summary matches only, use “search all” for everything.

3、 安装jdk

yum install java-1.8.0-opendk

Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
os | 3.6 kB 00:00:00
updates | 2.9 kB 00:00:00
Resolving Dependencies
–> Running transaction check
—> Package java-1.8.0-openjdk.x86_64 1:1.8.0.312.b07-1.el7_9 will be installed
–> Processing Dependency: java-1.8.0-openjdk-headless(x86-64) = 1:1.8.0.312.b07-1.el7_9 for package: 1:java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64
–> Processing Dependency: xorg-x11-fonts-Type1 for package: 1:java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64
–> Processing Dependency: libjvm.so(SUNWprivate_1.1)(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64
–> Processing Dependency: libjava.so(SUNWprivate_1.1)(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64
–> Processing Dependency: libjvm.so()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64
–> Processing Dependency: libjava.so()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64
–> Processing Dependency: libgif.so.4()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64
–> Processing Dependency: libXtst.so.6()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64
–> Running transaction check
—> Package giflib.x86_64 0:4.1.6-9.el7 will be installed
–> Processing Dependency: libSM.so.6()(64bit) for package: giflib-4.1.6-9.el7.x86_64
–> Processing Dependency: libICE.so.6()(64bit) for package: giflib-4.1.6-9.el7.x86_64
—> Package java-1.8.0-openjdk-headless.x86_64 1:1.8.0.312.b07-1.el7_9 will be installed
–> Processing Dependency: tzdata-java >= 2021a for package: 1:java-1.8.0-openjdk-headless-1.8.0.312.b07-1.el7_9.x86_64
–> Processing Dependency: copy-jdk-configs >= 3.3 for package: 1:java-1.8.0-openjdk-headless-1.8.0.312.b07-1.el7_9.x86_64
–> Processing Dependency: pcsc-lite-libs(x86-64) for package: 1:java-1.8.0-openjdk-headless-1.8.0.312.b07-1.el7_9.x86_64
–> Processing Dependency: lksctp-tools(x86-64) for package: 1:java-1.8.0-openjdk-headless-1.8.0.312.b07-1.el7_9.x86_64
–> Processing Dependency: jpackage-utils for package: 1:java-1.8.0-openjdk-headless-1.8.0.312.b07-1.el7_9.x86_64
—> Package libXtst.x86_64 0:1.2.3-1.el7 will be installed
—> Package xorg-x11-fonts-Type1.noarch 0:7.5-9.el7 will be installed
–> Processing Dependency: ttmkfdir for package: xorg-x11-fonts-Type1-7.5-9.el7.noarch
–> Processing Dependency: ttmkfdir for package: xorg-x11-fonts-Type1-7.5-9.el7.noarch
–> Processing Dependency: mkfontdir for package: xorg-x11-fonts-Type1-7.5-9.el7.noarch
–> Processing Dependency: mkfontdir for package: xorg-x11-fonts-Type1-7.5-9.el7.noarch
–> Running transaction check
—> Package copy-jdk-configs.noarch 0:3.3-10.el7_5 will be installed
—> Package javapackages-tools.noarch 0:3.4.1-11.el7 will be installed
–> Processing Dependency: python-javapackages = 3.4.1-11.el7 for package: javapackages-tools-3.4.1-11.el7.noarch
–> Processing Dependency: libxslt for package: javapackages-tools-3.4.1-11.el7.noarch
—> Package libICE.x86_64 0:1.0.9-9.el7 will be installed
—> Package libSM.x86_64 0:1.2.2-2.el7 will be installed
—> Package lksctp-tools.x86_64 0:1.0.17-2.el7 will be installed
—> Package pcsc-lite-libs.x86_64 0:1.8.8-8.el7 will be installed
—> Package ttmkfdir.x86_64 0:3.0.9-42.el7 will be installed
—> Package tzdata-java.noarch 0:2021e-1.el7 will be installed
—> Package xorg-x11-font-utils.x86_64 1:7.5-21.el7 will be installed
–> Processing Dependency: libfontenc.so.1()(64bit) for package: 1:xorg-x11-font-utils-7.5-21.el7.x86_64
–> Running transaction check
—> Package libfontenc.x86_64 0:1.1.3-3.el7 will be installed
—> Package libxslt.x86_64 0:1.1.28-6.el7 will be installed
—> Package python-javapackages.noarch 0:3.4.1-11.el7 will be installed
–> Processing Dependency: python-lxml for package: python-javapackages-3.4.1-11.el7.noarch
–> Running transaction check
—> Package python-lxml.x86_64 0:3.2.1-4.el7 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================
Package Arch Version Repository Size
===========================================================================================================
Installing:
java-1.8.0-openjdk x86_64 1:1.8.0.312.b07-1.el7_9 updates 313 k
Installing for dependencies:
copy-jdk-configs noarch 3.3-10.el7_5 os 21 k
giflib x86_64 4.1.6-9.el7 os 40 k
java-1.8.0-openjdk-headless x86_64 1:1.8.0.312.b07-1.el7_9 updates 33 M
javapackages-tools noarch 3.4.1-11.el7 os 73 k
libICE x86_64 1.0.9-9.el7 os 66 k
libSM x86_64 1.2.2-2.el7 os 39 k
libXtst x86_64 1.2.3-1.el7 os 20 k
libfontenc x86_64 1.1.3-3.el7 os 31 k
libxslt x86_64 1.1.28-6.el7 os 242 k
lksctp-tools x86_64 1.0.17-2.el7 os 88 k
pcsc-lite-libs x86_64 1.8.8-8.el7 os 34 k
python-javapackages noarch 3.4.1-11.el7 os 31 k
python-lxml x86_64 3.2.1-4.el7 os 758 k
ttmkfdir x86_64 3.0.9-42.el7 os 48 k
tzdata-java noarch 2021e-1.el7 updates 190 k
xorg-x11-font-utils x86_64 1:7.5-21.el7 os 104 k
xorg-x11-fonts-Type1 noarch 7.5-9.el7 os 521 k

Transaction Summary
===========================================================================================================
Install 1 Package (+17 Dependent packages)

Total download size: 36 M
Installed size: 117 M
Downloading packages:
(1/18): copy-jdk-configs-3.3-10.el7_5.noarch.rpm | 21 kB 00:00:00
(2/18): giflib-4.1.6-9.el7.x86_64.rpm | 40 kB 00:00:00
(3/18): javapackages-tools-3.4.1-11.el7.noarch.rpm | 73 kB 00:00:00
(4/18): libICE-1.0.9-9.el7.x86_64.rpm | 66 kB 00:00:00
(5/18): java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64.rpm | 313 kB 00:00:00
(6/18): libSM-1.2.2-2.el7.x86_64.rpm | 39 kB 00:00:00
(7/18): libXtst-1.2.3-1.el7.x86_64.rpm | 20 kB 00:00:00
(8/18): libfontenc-1.1.3-3.el7.x86_64.rpm | 31 kB 00:00:00
(9/18): lksctp-tools-1.0.17-2.el7.x86_64.rpm | 88 kB 00:00:00
(10/18): libxslt-1.1.28-6.el7.x86_64.rpm | 242 kB 00:00:00
(11/18): pcsc-lite-libs-1.8.8-8.el7.x86_64.rpm | 34 kB 00:00:00
(12/18): python-javapackages-3.4.1-11.el7.noarch.rpm | 31 kB 00:00:00
(13/18): ttmkfdir-3.0.9-42.el7.x86_64.rpm | 48 kB 00:00:00
(14/18): xorg-x11-font-utils-7.5-21.el7.x86_64.rpm | 104 kB 00:00:00
(15/18): python-lxml-3.2.1-4.el7.x86_64.rpm | 758 kB 00:00:00
(16/18): tzdata-java-2021e-1.el7.noarch.rpm | 190 kB 00:00:00
(17/18): xorg-x11-fonts-Type1-7.5-9.el7.noarch.rpm | 521 kB 00:00:00
(18/18): java-1.8.0-openjdk-headless-1.8.0.312.b07-1.el7_9.x86_64.rpm | 33 MB 00:00:02
-----------------------------------------------------------------------------------------------------------
Total 14 MB/s | 36 MB 00:00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libICE-1.0.9-9.el7.x86_64 1/18
Installing : libxslt-1.1.28-6.el7.x86_64 2/18
Installing : python-lxml-3.2.1-4.el7.x86_64 3/18
Installing : python-javapackages-3.4.1-11.el7.noarch 4/18
Installing : javapackages-tools-3.4.1-11.el7.noarch 5/18
Installing : libSM-1.2.2-2.el7.x86_64 6/18
Installing : giflib-4.1.6-9.el7.x86_64 7/18
Installing : pcsc-lite-libs-1.8.8-8.el7.x86_64 8/18
Installing : copy-jdk-configs-3.3-10.el7_5.noarch 9/18
Installing : lksctp-tools-1.0.17-2.el7.x86_64 10/18
Installing : libfontenc-1.1.3-3.el7.x86_64 11/18
Installing : 1:xorg-x11-font-utils-7.5-21.el7.x86_64 12/18
Installing : tzdata-java-2021e-1.el7.noarch 13/18
Installing : 1:java-1.8.0-openjdk-headless-1.8.0.312.b07-1.el7_9.x86_64 14/18
Installing : libXtst-1.2.3-1.el7.x86_64 15/18
Installing : ttmkfdir-3.0.9-42.el7.x86_64 16/18
Installing : xorg-x11-fonts-Type1-7.5-9.el7.noarch 17/18
Installing : 1:java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64 18/18
Verifying : 1:xorg-x11-font-utils-7.5-21.el7.x86_64 1/18
Verifying : libxslt-1.1.28-6.el7.x86_64 2/18
Verifying : libICE-1.0.9-9.el7.x86_64 3/18
Verifying : giflib-4.1.6-9.el7.x86_64 4/18
Verifying : xorg-x11-fonts-Type1-7.5-9.el7.noarch 5/18
Verifying : libSM-1.2.2-2.el7.x86_64 6/18
Verifying : python-javapackages-3.4.1-11.el7.noarch 7/18
Verifying : python-lxml-3.2.1-4.el7.x86_64 8/18
Verifying : ttmkfdir-3.0.9-42.el7.x86_64 9/18
Verifying : 1:java-1.8.0-openjdk-headless-1.8.0.312.b07-1.el7_9.x86_64 10/18
Verifying : 1:java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64 11/18
Verifying : libXtst-1.2.3-1.el7.x86_64 12/18
Verifying : javapackages-tools-3.4.1-11.el7.noarch 13/18
Verifying : tzdata-java-2021e-1.el7.noarch 14/18
Verifying : libfontenc-1.1.3-3.el7.x86_64 15/18
Verifying : lksctp-tools-1.0.17-2.el7.x86_64 16/18
Verifying : copy-jdk-configs-3.3-10.el7_5.noarch 17/18
Verifying : pcsc-lite-libs-1.8.8-8.el7.x86_64 18/18

Installed:
java-1.8.0-openjdk.x86_64 1:1.8.0.312.b07-1.el7_9

Dependency Installed:
copy-jdk-configs.noarch 0:3.3-10.el7_5 giflib.x86_64 0:4.1.6-9.el7
java-1.8.0-openjdk-headless.x86_64 1:1.8.0.312.b07-1.el7_9 javapackages-tools.noarch 0:3.4.1-11.el7
libICE.x86_64 0:1.0.9-9.el7 libSM.x86_64 0:1.2.2-2.el7
libXtst.x86_64 0:1.2.3-1.el7 libfontenc.x86_64 0:1.1.3-3.el7
libxslt.x86_64 0:1.1.28-6.el7 lksctp-tools.x86_64 0:1.0.17-2.el7
pcsc-lite-libs.x86_64 0:1.8.8-8.el7 python-javapackages.noarch 0:3.4.1-11.el7
python-lxml.x86_64 0:3.2.1-4.el7 ttmkfdir.x86_64 0:3.0.9-42.el7
tzdata-java.noarch 0:2021e-1.el7 xorg-x11-font-utils.x86_64 1:7.5-21.el7
xorg-x11-fonts-Type1.noarch 0:7.5-9.el7

Complete!
安装完毕

4、检验安装

java -version

openjdk version "1.8.0\_312"  
OpenJDK Runtime Environment (build 1.8.0\_312-b07)  
OpenJDK 64-Bit Server VM (build 25.312-b07, mixed mode)  

5、安装路径

yum 命令安装默认安装路径为 /usr/lib/jvm

cd /usr/lib/jvm

[root@VM-24-9-centos etc]# cd /usr/lib/jvm
[root@VM-24-9-centos jvm]# ll
total 4
drwxr-xr-x 3 root root 4096 Jan 6 11:11 java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64
lrwxrwxrwx 1 root root 21 Jan 6 11:11 jre -> /etc/alternatives/jre
lrwxrwxrwx 1 root root 27 Jan 6 11:11 jre-1.8.0 -> /etc/alternatives/jre_1.8.0
lrwxrwxrwx 1 root root 35 Jan 6 11:11 jre-1.8.0-openjdk -> /etc/alternatives/jre_1.8.0_openjdk
lrwxrwxrwx 1 root root 51 Jan 6 11:11 jre-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64 -> java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64/jre
lrwxrwxrwx 1 root root 29 Jan 6 11:11 jre-openjdk -> /etc/alternatives/jre_openjdk

/etc/alternatives 的目录下面会有个java链接,指向/usr/lib/jvm/ava-1.8.0-openjdk-1.8.0.312.b07-1.el7\_9.x86\_64

[root@VM-24-9-centos etc]# cd /etc/alternatives/
[root@VM-24-9-centos alternatives]# ll
total 124
lrwxrwxrwx 1 root root 77 Jan 6 11:11 alt-java -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64/jre/bin/alt-java
lrwxrwxrwx 1 root root 81 Jan 6 11:11 alt-java.1.gz -> /usr/share/man/man1/alt-java-java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64.1.gz
lrwxrwxrwx 1 root root 39 Nov 23 17:53 cifs-idmap-plugin -> /usr/lib64/cifs-utils/cifs_idmap_sss.so
lrwxrwxrwx 1 root root 73 Jan 6 11:11 java -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64/jre/bin/java
lrwxrwxrwx 1 root root 77 Jan 6 11:11 java.1.gz -> /usr/share/man/man1/java-java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64.1.gz
lrwxrwxrwx 1 root root 72 Jan 6 11:11 jjs -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64/jre/bin/jjs
lrwxrwxrwx 1 root root 76 Jan 6 11:11 jjs.1.gz -> /usr/share/man/man1/jjs-java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64.1.gz
lrwxrwxrwx 1 root root 64 Jan 6 11:11 jre -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64/jre
lrwxrwxrwx 1 root root 64 Jan 6 11:11 jre_1.8.0 -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64/jre
lrwxrwxrwx 1 root root 64 Jan 6 11:11 jre_1.8.0_exports -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64/jre
lrwxrwxrwx 1 root root 59 Jan 6 11:11 jre_1.8.0_openjdk -> /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64
lrwxrwxrwx 1 root root 68 Jan 6 11:11 jre_1.8.0_openjdk_exports -> /usr/lib/jvm-exports/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64
lrwxrwxrwx 1 root root 67 Jan 6 11:11 jre_exports -> /usr/lib/jvm-exports/jre-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64
lrwxrwxrwx 1 root root 64 Jan 6 11:11 jre_openjdk -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64/jre
lrwxrwxrwx 1 root root 64 Jan 6 11:11 jre_openjdk_exports -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64/jre
lrwxrwxrwx 1 root root 76 Jan 6 11:11 keytool -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64/jre/bin/keytool
lrwxrwxrwx 1 root root 80 Jan 6 11:11 keytool.1.gz -> /usr/share/man/man1/keytool-java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64.1.gz
lrwxrwxrwx 1 root root 15 Nov 23 17:52 ld -> /usr/bin/ld.bfd
lrwxrwxrwx 1 root root 34 Nov 23 17:52 libnssckbi.so.x86_64 -> /usr/lib64/pkcs11/p11-kit-trust.so
lrwxrwxrwx 1 root root 26 Sep 2 2020 mta -> /usr/sbin/sendmail.postfix
lrwxrwxrwx 1 root root 40 Sep 2 2020 mta-aliasesman -> /usr/share/man/man5/aliases.postfix.5.gz
lrwxrwxrwx 1 root root 22 Sep 2 2020 mta-mailq -> /usr/bin/mailq.postfix
lrwxrwxrwx 1 root root 38 Sep 2 2020 mta-mailqman -> /usr/share/man/man1/mailq.postfix.1.gz
lrwxrwxrwx 1 root root 27 Sep 2 2020 mta-newaliases -> /usr/bin/newaliases.postfix
lrwxrwxrwx 1 root root 43 Sep 2 2020 mta-newaliasesman -> /usr/share/man/man1/newaliases.postfix.1.gz
lrwxrwxrwx 1 root root 23 Sep 2 2020 mta-pam -> /etc/pam.d/smtp.postfix
lrwxrwxrwx 1 root root 22 Sep 2 2020 mta-rmail -> /usr/bin/rmail.postfix
lrwxrwxrwx 1 root root 25 Sep 2 2020 mta-sendmail -> /usr/lib/sendmail.postfix
lrwxrwxrwx 1 root root 41 Sep 2 2020 mta-sendmailman -> /usr/share/man/man1/sendmail.postfix.1.gz
lrwxrwxrwx 1 root root 73 Jan 6 11:11 orbd -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64/jre/bin/orbd
lrwxrwxrwx 1 root root 77 Jan 6 11:11 orbd.1.gz -> /usr/share/man/man1/orbd-java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64.1.gz
lrwxrwxrwx 1 root root 76 Jan 6 11:11 pack200 -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64/jre/bin/pack200
lrwxrwxrwx 1 root root 80 Jan 6 11:11 pack200.1.gz -> /usr/share/man/man1/pack200-java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64.1.gz
lrwxrwxrwx 1 root root 79 Jan 6 11:11 policytool -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64/jre/bin/policytool
lrwxrwxrwx 1 root root 83 Jan 6 11:11 policytool.1.gz -> /usr/share/man/man1/policytool-java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64.1.gz
lrwxrwxrwx 1 root root 73 Jan 6 11:11 rmid -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64/jre/bin/rmid
lrwxrwxrwx 1 root root 77 Jan 6 11:11 rmid.1.gz -> /usr/share/man/man1/rmid-java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64.1.gz
lrwxrwxrwx 1 root root 80 Jan 6 11:11 rmiregistry -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64/jre/bin/rmiregistry
lrwxrwxrwx 1 root root 84 Jan 6 11:11 rmiregistry.1.gz -> /usr/share/man/man1/rmiregistry-java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64.1.gz
lrwxrwxrwx 1 root root 79 Jan 6 11:11 servertool -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64/jre/bin/servertool
lrwxrwxrwx 1 root root 83 Jan 6 11:11 servertool.1.gz -> /usr/share/man/man1/servertool-java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64.1.gz
lrwxrwxrwx 1 root root 78 Jan 6 11:11 tnameserv -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64/jre/bin/tnameserv
lrwxrwxrwx 1 root root 82 Jan 6 11:11 tnameserv.1.gz -> /usr/share/man/man1/tnameserv-java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64.1.gz
lrwxrwxrwx 1 root root 78 Jan 6 11:11 unpack200 -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64/jre/bin/unpack200
lrwxrwxrwx 1 root root 82 Jan 6 11:11 unpack200.1.gz -> /usr/share/man/man1/unpack200-java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64.1.gz

6、设置jdk环境变量

vim /etc/profile
在文件最后加入如下配置:
 #set java environment  
JAVA\_HOME=/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.312.b07-1.el7\_9.x86\_64 ==》这里指的是

PATH=$PATH:$JAVA\_HOME/bin  
CLASSPATH=.:$JAVA\_HOME/lib/dt.jar:$JAVA\_HOME/lib/tools.jar  
export JAVA\_HOME CLASSPATH PATH

保存退出

7、使profile文件立即生效

. /etc/profile // . 后面有个空格

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值