一、通過yum命令線上安裝jdk 1.查看雲端目前支持安裝的jdk版本 2.選擇版本後,安裝(執行以下命令會自動安裝jdk相關依賴) 3.安裝完成,驗證是否安裝成功 4.通過搜索java文件,查找jdk預設安裝目錄 提示:通過yum命令線上安裝jdk簡單、快捷、無需配置環境變數即可使用java相關服 ...
一、通過yum命令線上安裝jdk
1.查看雲端目前支持安裝的jdk版本
[root@localhost ~]# yum search java|grep jdk ldapjdk-javadoc.noarch : Javadoc for ldapjdk 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 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 java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation java-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundle java-1.8.0-openjdk.i686 : OpenJDK Runtime Environment java-1.8.0-openjdk.x86_64 : OpenJDK 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-accessibility-debug.i686 : OpenJDK accessibility connector java-1.8.0-openjdk-accessibility-debug.x86_64 : OpenJDK accessibility connector java-1.8.0-openjdk-debug.i686 : OpenJDK Runtime Environment with full debug on java-1.8.0-openjdk-debug.x86_64 : OpenJDK Runtime Environment with full debug on java-1.8.0-openjdk-demo.i686 : OpenJDK Demos java-1.8.0-openjdk-demo.x86_64 : OpenJDK Demos java-1.8.0-openjdk-demo-debug.i686 : OpenJDK Demos with full debug on java-1.8.0-openjdk-demo-debug.x86_64 : OpenJDK Demos with full debug on java-1.8.0-openjdk-devel.i686 : OpenJDK Development Environment java-1.8.0-openjdk-devel.x86_64 : OpenJDK Development Environment java-1.8.0-openjdk-devel-debug.i686 : OpenJDK Development Environment with full java-1.8.0-openjdk-devel-debug.x86_64 : OpenJDK Development Environment with java-1.8.0-openjdk-headless.i686 : OpenJDK Runtime Environment java-1.8.0-openjdk-headless.x86_64 : OpenJDK Runtime Environment java-1.8.0-openjdk-headless-debug.i686 : OpenJDK Runtime Environment with full java-1.8.0-openjdk-headless-debug.x86_64 : OpenJDK Runtime Environment with full java-1.8.0-openjdk-javadoc.noarch : OpenJDK API Documentation java-1.8.0-openjdk-javadoc-debug.noarch : OpenJDK API Documentation for packages java-1.8.0-openjdk-javadoc-zip.noarch : OpenJDK API Documentation compressed in java-1.8.0-openjdk-javadoc-zip-debug.noarch : OpenJDK API Documentation java-1.8.0-openjdk-src.i686 : OpenJDK Source Bundle java-1.8.0-openjdk-src.x86_64 : OpenJDK Source Bundle java-1.8.0-openjdk-src-debug.i686 : OpenJDK Source Bundle for packages with java-1.8.0-openjdk-src-debug.x86_64 : OpenJDK Source Bundle for packages with ldapjdk.noarch : The Mozilla LDAP Java SDK
2.選擇版本後,安裝(執行以下命令會自動安裝jdk相關依賴)
[root@localhost ~]# yum install -y java-1.8.0-openjdk 已載入插件:fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.zju.edu.cn * extras: mirror.bit.edu.cn * updates: mirrors.aliyun.com 正在解決依賴關係 --> 正在檢查事務 ---> 軟體包 java-1.8.0-openjdk.x86_64.1.1.8.0.151-5.b12.el7_4 將被 安裝 --> 正在處理依賴關係 java-1.8.0-openjdk-headless(x86-64) = 1:1.8.0.151-5.b12.el7_4,它被軟體包 1:java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 需要 --> 正在處理依賴關係 xorg-x11-fonts-Type1,它被軟體包 1:java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 需要 --> 正在處理依賴關係 libpng15.so.15(PNG15_0)(64bit),它被軟體包 1:java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 需要 --> 正在處理依賴關係 libjvm.so(SUNWprivate_1.1)(64bit),它被軟體包 1:java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 需要 --> 正在處理依賴關係 libjpeg.so.62(LIBJPEG_6.2)(64bit),它被軟體包 1:java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 需要 --> 正在處理依賴關係 libjli.so(SUNWprivate_1.1)(64bit),它被軟體包 1:java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 需要 --> 正在處理依賴關係 libjava.so(SUNWprivate_1.1)(64bit),它被軟體包 1:java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 需要 --> 正在處理依賴關係 fontconfig(x86-64),它被軟體包 1:java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 需要 --> 正在處理依賴關係 libpng15.so.15()(64bit),它被軟體包 1:java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 需要 --> 正在處理依賴關係 libjvm.so()(64bit),它被軟體包 1:java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 需要 --> 正在處理依賴關係 libjpeg.so.62()(64bit),它被軟體包 1:java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 需要 --> 正在處理依賴關係 libjli.so()(64bit),它被軟體包 1:java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 需要 --> 正在處理依賴關係 libjava.so()(64bit),它被軟體包 1:java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 需要 --> 正在處理依賴關係 libgif.so.4()(64bit),它被軟體包 1:java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 需要 --> 正在處理依賴關係 libawt.so()(64bit),它被軟體包 1:java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 需要 --> 正在處理依賴關係 libXtst.so.6()(64bit),它被軟體包 1:java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 需要 --> 正在處理依賴關係 libXrender.so.1()(64bit),它被軟體包 1:java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 需要 --> 正在處理依賴關係 libXi.so.6()(64bit),它被軟體包 1:java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 需要 --> 正在處理依賴關係 libXext.so.6()(64bit),它被軟體包 1:java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 需要 --> 正在處理依賴關係 libXcomposite.so.1()(64bit),它被軟體包 1:java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 需要 --> 正在處理依賴關係 libX11.so.6()(64bit),它被軟體包 1:java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 需要
... ...
3.安裝完成,驗證是否安裝成功
[root@localhost ~]# java -version openjdk version "1.8.0_151" OpenJDK Runtime Environment (build 1.8.0_151-b12) OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)
4.通過搜索java文件,查找jdk預設安裝目錄
[root@localhost ~]# find / -name 'java' /etc/pki/ca-trust/extracted/java /etc/pki/java /etc/java /etc/alternatives/java /var/lib/alternatives/java /usr/bin/java /usr/lib/java /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64/jre/bin/java /usr/share/java
備註:通過yum命令線上安裝jdk簡單、快捷、無需配置環境變數即可使用java相關服務。