How to uninstall built-in OpenJDK in CentOS

Source: Internet
Author: User
Tags chmod mixed centos


Check whether JDK is installed in Linux.

The installed CentOS comes with OpenJdk and uses the java-version command. The following information is displayed:

Java version "1.6.0 & Prime;
OpenJDK Runtime Environment (build 1.6.0-b09)
OpenJDK 64-Bit Server VM (build 1.6.0-b09, mixed mode)
It is best to uninstall openjdk first and install the jdk of sun.

Check rpm-qa | grep java first

The following information is displayed:

Java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
Java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5
Uninstall open jdk
Rpm-e-nodeps java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
Rpm-e-nodeps java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5

There are other commands

Rpm-qa | grep gcj
Rpm-qa | grep jdk

If openjdk source cannot be found, you can uninstall it like this.

Yum-y remove java java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
Yum-y remove java java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5
1. # rpm-qa | grep jdk to view jdk information or directly execute or rpm-q jdk or java-version
2. # rpm-qa | grep gcj confirm the gcj version number
3, # yum-y remove java-1.4.2-gcj-compat uninstall gcj


After installation, we still need to use jdk. So let's install a sun jdk.

Download Sun's JDK. I downloaded

Jdk-6u37-linux-i586-rpm.bin

For a 64-bit system, download:

Jdk-6u37-linux-x64-rpm.bin

And other 64-bit dedicated packages

 

Create a java directory under the/usr directory and put the downloaded file under the/usr/java Directory

Change the file to an executable file (chmod 777 ):

[Root @ dc-01 java] # chmod 777 jdk-6u37-linux-i586-rpm.bin

Then execute this file to install it:

[Root @ dc-01 java] #./jdk-6u37-linux-i586-rpm.bin
 
Press Enter.

Done appears.
 

The installation is now complete.

 

Configure JDK:

Vi/etc/profile open the profile file and add the following at the end of the profile file:

JAVA_HOME =/usr/java/jdk1.6.0 _ 37
PATH = $ JAVA_HOME/bin: $ PATH
CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar
Export JAVA_HOME
Export PATH
Export CLASSPATH
 
Save and close the profile file, and run the source/etc/profile command to make the modification take effect.

Run java-version to check the java version:

[Root @ dc-01 java] # java-version

Java version "1.6.0 _ 37"
Java (TM) SE Runtime Environment (build 1.6.0 _ 37-b06)
Java HotSpot (TM) Client VM (build between 12-b01, mixed mode, sharing)
[Root @ dc-01 java] #
========================================================== ==========

 

So far, the entire installation process is complete.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.