View the installed JDK and uninstall the JDK under Linux

Source: Internet
Author: User
Tags lua

OPENJDK implementation of the Java platform as a GPL license (gpl-licensed)

The Java interpreter for GCC
Compiler: GCJ;
Interpreter: gij;

First, check 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 the 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 using the following method:

1) Uninstall the JDK version that comes with the system:
To view your own JDK:
#rpm-qa|grep GCJ
You may see a message similar to the following:
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 what you found above:
#rpm-e–nodeps java-1.4.2-gcj-compat-1.4.2.0-40jpp.115

2) Uninstall JKD version of RPM installation
To view the installed JDK:
#rpm-qa|grep JDK
You may see a message similar to the following:
Jdk-1.6.0_22-fcs
Unloading:
#rpm-E--nodeps Jdk-1.6.0_22-fcs

3) Locate the _uninst subdirectory of the JDK installation directory

• Execute commands at the shell terminal./uninstall.sh to uninstall the JDK

Third, download the new version of the JDK

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

Iv. Installing the JDK (with 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 the Jdk-6u22-linux-i586-rpm.bin
3. Add executable permissions to all users
#chmod +x Jdk-6u22-linux-i586-rpm.bin
4. Execute the document with the following command:
#./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 the root user, enter the directory where the jdk-6u22-linux-i586.rpm is stored, and execute the following command:
RPM-IVH jdk-6u22-linux-i586.rpm
Installing the software automatically installs 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 being used directly install RPM packages, use Alien instead!

This command can then be used:

rpm-ivh jdk-6u22-linux-i586.rpm--nodeps--force

v. Configuring environment variables:

If all users want to share the environment variables of the JDK, they can be set in the following way.

(It is advisable not to do so, in case other users are affected by other JDK usage.) )
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 want to run the file immediately after you modify it, you can only take effect the next time you re-enter the user. Source/etc/profile.
Remember to add $classpath to the CLASSPATH path: Otherwise you might get an error explaining the execution of the class file.

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

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

1. A non-root user environment variable is in effect, but after switching to the root user, use Javac and other commands to expire.

2. Environment variables written to/etc/profile automatically take effect after a reboot. Every time you open a terminal without restarting, you need to execute the source command as you said.

attached: How to install the tar type JDK:

First unzip the *.tar.gz

tar -xzvf *.tar.gz

Suppose the resulting folder is Java

Move it to/usr/

sudo mv java /usr/local

Then set the environment variables:

sudo vim /etc/profile

Open File

Enter at the end:

Export java_home=/usr/local/java export jre_home=/usr/local/java/jre export Classpath=.: $JAVA _home/lib: $JRE _home/lib: $CLASSPATH Span class= "hljs-built_in" >export path= $JAVA _home/bin: $JRE _home/bin: $PATH         

Modify default JDK in Ubuntu

Update-alternatives--Install/usr/bin/java JAVA/USR/localjava/bin /java  300 update -alternatives--install/usr/bin/javac javac  /usr/local/java/bin/javac 300      

This step adds our installed JDK to the Java menu.

update-alternatives --config java

Select the default JDK

java -version

View the installed JDK and uninstall the JDK under Linux

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.