CentOS7 線上安裝 java
阿新 • • 發佈:2018-11-12
使用的是騰訊雲 CentOS7 學生伺服器
1. 檢視自己伺服器是否安裝 Java
[[email protected]_0_10_centos ~]# yum list installed |grep java
如果什麼都沒顯示 代表沒有安裝
如果顯示如下 說明已經安裝 你可選擇解除安裝(末尾有如何解除安裝) 或使用 已安裝的java
【說明已安裝java1.8】
[[email protected] _0_10_centos ~]# yum list installed |grep java
java-1.8.0-openjdk.x86_64 1:1.8.0.181-3.b13.el7_5 @updates
java-1.8.0-openjdk-headless.x86_64 1:1.8.0.181-3.b13.el7_5 @updates
javapackages-tools.noarch 3.4.1-11.el7 @os
python-javapackages.noarch 3.4.1-11.el7 @os
tzdata-java.noarch 2018e-3.el7 @updates
[ [email protected]_0_10_centos ~]#
2. 查詢可以線上安裝的java版本
[[email protected]_0_10_centos ~]# yum -y list java* Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile 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.191-2.6.15.4.el7_5 updates java-1.7.0-openjdk-accessibility.x86_64 1:1.7.0.191-2.6.15.4.el7_5 updates java-1.7.0-openjdk-demo.x86_64 1:1.7.0.191-2.6.15.4.el7_5 updates java-1.7.0-openjdk-devel.x86_64 1:1.7.0.191-2.6.15.4.el7_5 updates java-1.7.0-openjdk-headless.x86_64 1:1.7.0.191-2.6.15.4.el7_5 updates java-1.7.0-openjdk-javadoc.noarch 1:1.7.0.191-2.6.15.4.el7_5 updates java-1.7.0-openjdk-src.x86_64 1:1.7.0.191-2.6.15.4.el7_5 updates java-1.8.0-openjdk.i686 1:1.8.0.181-3.b13.el7_5 updates java-1.8.0-openjdk.x86_64 1:1.8.0.181-3.b13.el7_5 updates java-1.8.0-openjdk-accessibility.i686 1:1.8.0.181-3.b13.el7_5 updates java-1.8.0-openjdk-accessibility.x86_64 1:1.8.0.181-3.b13.el7_5 updates ... ... 中間省略 ... javapackages-tools.noarch 3.4.1-11.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
3.選擇自己需要的版本進行安裝(我選擇java1.8)
[[email protected]_0_10_centos ~]# yum -y install java-1.8.0-openjdk.x86_64
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
epel | 3.2 kB 00:00:00
extras | 3.4 kB 00:00:00
mysql-connectors-community | 2.5 kB 00:00:00
mysql-tools-community | 2.5 kB 00:00:00
...
中間安裝省略
...
xorg-x11-fonts-Type1.noarch 0:7.5-9.el7
Dependency Updated:
nspr.x86_64 0:4.19.0-1.el7_5 nss.x86_64 0:3.36.0-7.el7_5
nss-softokn.x86_64 0:3.36.0-5.el7_5 nss-softokn-freebl.x86_64 0:3.36.0-5.el7_5
nss-sysinit.x86_64 0:3.36.0-7.el7_5 nss-tools.x86_64 0:3.36.0-7.el7_5
nss-util.x86_64 0:3.36.0-1.el7_5
Complete! (出現Complete!表示安裝成功)
4. 查詢java是否可以使用
[[email protected]_0_10_centos ~]# java -version
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)
java 解除安裝
查詢自己安裝的java
[[email protected]_0_10_centos ~]# yum list installed |grep java
java-1.8.0-openjdk.x86_64 1:1.8.0.181-3.b13.el7_5 @updates
java-1.8.0-openjdk-headless.x86_64 1:1.8.0.181-3.b13.el7_5 @updates
javapackages-tools.noarch 3.4.1-11.el7 @os
python-javapackages.noarch 3.4.1-11.el7 @os
tzdata-java.noarch 2018e-3.el7 @updates
使用自己查詢的java名字進行解除安裝
[[email protected]_0_10_centos ~]# yum -y remove java-1.8.0-openjdk*
解除安裝tzdata
yum -y remove tzdata-java.noarch
解除安裝完成