Install java in yum mode in Centos
Check whether the JDK that comes with CentOS has been installed.
◆Input: yum list installed |grep java.
If there is a built-in JDK, how to uninstall the Java environment that comes with CentOS?
◆Uninstall JDK related files input: yum -y remove java-1.7.0-openjdk*.
◆Uninstall tzdata-java input: yum -y remove tzdata-java.noarch.
When the result is displayed as Complete! The uninstallation is complete.
Note: "*" means to uninstall all openjdk related files of java 1.7.0.
Check whether the CentOS system network connection is normal.
◆Using yum method to install needs to connect to the network to download the corresponding Java installation files, so you need to use the ping command to test the network; for example, ping Baidu URL.
Check the Java installation package in the yum library.
◆Input: yum -y list java*.
[ root@beta-new1 www]# yum -y list java*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
- base: centos.ustc.edu.cn
- extras: centos.ustc.edu.cn
- updates: centos.ustc.edu.cn
base | 3.7 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
Available Packages
java-1.5.0-gcj.x86_64 1.5.0.0-29.1.el6 base
java-1.5.0-gcj-devel.x86_64 1.5.0.0-29.1.el6 base
java-1.5.0-gcj-javadoc.x86_64 1.5.0.0-29.1.el6 base
java-1.5.0-gcj-src.x86_64 1.5.0.0-29.1.el6 base
java-1.6.0-openjdk.x86_64 1:1.6.0.40-1.13.12.6.el6_8 updates
java-1.6.0-openjdk-demo.x86_64 1:1.6.0.40-1.13.12.6.el6_8 updates
java-1.6.0-openjdk-devel.x86_64 1:1.6.0.40-1.13.12.6.el6_8 updates
java-1.6.0-openjdk-javadoc.x86_64 1:1.6.0.40-1.13.12.6.el6_8 updates
java-1.6.0-openjdk-src.x86_64 1:1.6.0.40-1.13.12.6.el6_8 updates
java-1.7.0-openjdk.x86_64 1:1.7.0.111-2.6.7.2.el6_8 updates
java-1.7.0-openjdk-demo.x86_64 1:1.7.0.111-2.6.7.2.el6_8 updates
java-1.7.0-openjdk-devel.x86_64 1:1.7.0.111-2.6.7.2.el6_8 updates
java-1.7.0-openjdk-javadoc.noarch 1:1.7.0.111-2.6.7.2.el6_8 updates
java-1.7.0-openjdk-src.x86_64 1:1.7.0.111-2.6.7.2.el6_8 updates
java-1.8.0-openjdk.x86_64 1:1.8.0.101-3.b13.el6_8 updates
java-1.8.0-openjdk-debug.x86_64 1:1.8.0.101-3.b13.el6_8 updates
java-1.8.0-openjdk-demo.x86_64 1:1.8.0.101-3.b13.el6_8 updates
java-1.8.0-openjdk-demo-debug.x86_64 1:1.8.0.101-3.b13.el6_8 updates
java-1.8.0-openjdk-devel.x86_64 1:1.8.0.101-3.b13.el6_8 updates
java-1.8.0-openjdk-devel-debug.x86_64 1:1.8.0.101-3.b13.el6_8 updates
java-1.8.0-openjdk-headless.x86_64 1:1.8.0.101-3.b13.el6_8 updates
java-1.8.0-openjdk-headless-debug.x86_64 1:1.8.0.101-3.b13.el6_8 updates
java-1.8.0-openjdk-javadoc.noarch 1:1.8.0.101-3.b13.el6_8 updates
java-1.8.0-openjdk-javadoc-debug.noarch 1:1.8.0.101-3.b13.el6_8 updates
java-1.8.0-openjdk-src.x86_64 1:1.8.0.101-3.b13.el6_8 updates
java-1.8.0-openjdk-src-debug.x86_64 1:1.8.0.101-3.b13.el6_8 updates
java_cup.x86_64 1:0.10k-5.el6 base
java_cup-javadoc.x86_64 1:0.10k-5.el6 base
java_cup-manual.x86_64 1:0.10k-5.el6 base
javacc.x86_64 4.1-0.5.el6 base
javacc-demo.x86_64 4.1-0.5.el6 base
javacc-manual.x86_64 4.1-0.5.el6 base
javassist.noarch 3.9.0-6.el6 base
javassist-javadoc.noarch 3.9.0-6.el6 base
Take java-1.7.0 in yum library as an example
Note: "" means to install all relevant Java programs of java-1.7.0.
[ root@beta-new1 www]# yum -y install java-1.7.0-openjdk
Check the version of Java just installed.
◆Enter: java -version to view the Java version;
◆Input: javac to view the usage of Java compiler commands