How to view the installed JDK and uninstall the JDK under Linux (recommended) _linux

Source: Internet
Author: User

First, view the installation path of the JDK:

Whereis Java
Which Java (Java execution path)
Echo $JAVA _home

Echo $PATH

Note: If you are in Windows, you can use:

Set Java_home: View JDK Installation path
Java-version: View JDK version

Second, uninstall the old version of the JDK:

1. Determine the version of JDK:

Rpm-qa | grep JDK

Rpm-qa | grep GCJ

The possible results are:

Libgcj-4.1.2-42.el5
java-1.4.2-gcj-compat-1.4.2.0-40jpp.115

2. Then uninstall:

Yum-y Remove java-1.4.2-gcj-compat-1.4.2.0-40jpp.115

If this method does not work, you can uninstall it by using the following methods:

1 Uninstall the system from the JDK version:
to view the self-brought JDK:
#rpm-qa|grep GCJ
You may see similar information as follows:
Libgcj-4.1.2-44.el5
java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
Use the RPM-E--nodeps command to delete the contents of the above lookup:
#rpm-e–nodeps java-1.4.2-gcj-compat-1.4.2.0-40jpp.115

2 Uninstall the JKD version of the RPM installation
to view the installed JDK:
#rpm-qa|grep JDK
You may see similar information as follows:
Jdk-1.6.0_22-fcs
Unloading:
#rpm-E--nodeps Jdk-1.6.0_22-fcs

3 Locate the JDK installation directory _uninst subdirectory

• Execute command at Shell Terminal./uninstall.sh can uninstall JDK

Third, download the new version of the JDK

Official address: http://www.oracle.com/technetwork/java/javase/downloads/index.htm

Iv. installation of JDK (take JDK1.6 as an example)

1, jdk1.6 provides the following two kinds of self-extracting files:
1) Jdk-6u22-linux-i586.bin
2) Jdk-6u22-linux-i586-rpm.bin

2, I downloaded is the Jdk-6u22-linux-i586-rpm.bin

3. Add executable permissions to all users
#chmod +x Jdk-6u22-linux-i586-rpm.bin

4, the implementation of the document, the following orders:
#./jdk-6u22-linux-i586-rpm.bin
After execution, some RPM packages are extracted, including jdk-6u22-linux-i586.rpm, which is the main package, followed by the installation of the main package.

5., switch to root user, enter the directory of JDK-6U22-LINUX-I586.RPM, execute the following command:
RPM-IVH jdk-6u22-linux-i586.rpm
The installation software will automatically install the JDK into the/usr/java/jdk-1.6.0_22-fcs directory

When installing on Linux, you will often encounter the following fail:

RPM should not is used directly install RPM packages, use alien instead!

Then use this command to:

RPM-IVH jdk-6u22-linux-i586.rpm--nodeps--force

v. Configure environment variables:

If all users want to share JDK environment variables, you can set them by using the following method.

(It is advisable not to do so, in the event that other users will be affected by other JDK.) )

In the/etc/profile file, add:
# Vi/etc/profile
Export Java_home=/usr/java/jdk-1.6.0_22-fcs
Export classpath= $CLASSPATH: $JAVA _home/lib: $JAVA _home/jre/lib
Export path= $JAVA _home/bin: $JAVA _home/jre/bin: $PATH: $HOME/bin

Note: If you modify the file, you want to take effect immediately and run # Source/etc/profile, otherwise it will only take effect the next time you go back to this user.

Remember to add $classpath to the CLASSPATH path: Otherwise it may be an error when interpreting the execution class file.

Of course, you can use a more thorough approach: Reboot command to reboot the machine.

Sometimes you may find that the environment variables configured in/etc/profile fail after the system restarts or reuse the SSH connection, possibly because

1. A non-root environment variable is in effect, but after switching to the root user, use Javac and so on to disable the command.

2. The environment variable written to the/etc/profile will automatically take effect after the reboot. Every time you open a terminal before rebooting, you must execute the source command as you described.

Attached: How to install the TAR type JDK:

First unzip the *.tar.gz

TAR-XZVF *.tar.gz assumes that the resulting folder is Java

Move it to/usr/

sudo mv Java/usr/local Then set the environment variable:

sudo vim/etc/profile Open File

At the end, enter:

Export Java_home=/usr/local/java export JRE_HOME=/USR/LOCAL/JAVA/JRE export classpath=.: $JAVA _home/lib: $JRE _home/ LIB: $CLASSPATH export path= $JAVA _home/bin: $JRE _home/bin: Modifying the default JDK in $PATHUbuntu

Update-alternatives--install/usr/bin/java Java/usr/localjava/bin/java update-alternatives--install/usr/bin/ Javac Javac/usr/local/java/bin/javac 300 Adds the JDK we installed to the Java menu in this step.

Update-alternatives--config java Select the default JDK

Java-version

The above Linux to view the installed JDK and uninstall the JDK method (recommended) is small to share all the content of everyone, hope to give you a reference, but also hope that we support the cloud habitat community.

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.