Uninstalling and installing the JDK on Linux

Source: Internet
Author: User

1. Uninstall the default JDK:
Log in to the system with the root user and open a terminal input

#rpm-qa | grep GCJ

Display content contains the following two lines of information

                        # java-1.4.2-gcj-compat-1.4.2.0            # java-1.4.2-gcj-compat-devel-l.4.2.0

Start uninstalling the JDK

# rpm  -e  java-1.4.2-gcj-compat-1.4.2.0# rpm  -e  java-1.4.2-gcj-compat-devel-l.4.2.0

Uninstall any other JDK you have installed and use RPM-E java-xxxx directly

2. Install the JDK:
Download JDK installation files Jdk-6u10-linux-i586-rpm.bin
Upload the Jdk-6u10-linux-i586-rpm.bin to the Linux server and execute the following command under the shell

    #chmod  755  jdk-6u10-linux-i586-rpm.bin    #./jdk-6u10-linux-i586-rpm.bin

There will be a sun agreement, a few times the space bar, when asked whether or not to agree, knock Yes.
The program will automatically generate a jdk-6u10-linux-i586-rpm.rpm file, which is the main package, which is installed below:
#rpm-IVH jdk-6u10-linux-i586-rpm.rpm (installed by default in/usr/java)

3. Set environment variables (. bashrc files):
Modify the. bashrc file in the user's home directory to add the JDK environment variable.

    #vi  .bashrc    set JAVA_HOME=/usr/java/    export JAVA_HOME    set PATH=$PATH:$JAVA_HOME/bin    export PATH    set CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar    export CLASSPATH    #source  ./bashrc

This can also be done by changing the/etc/profile, but it is not recommended because such a setting will be effective for all users ' shells and will have an impact on system security. Here's a check to see if the variable setting is in effect (logout before verification and then re-login). If you want a user to have permission to run Java commands, simply modify their bash initialization file.

Environment variable configuration (/etc/profile file):
#vi/etc/profile
In the profile file, add the following:

    JAVA_HOME=/usr/java/jdk1.6.0_10    JRE_HOME=/usr/java/jdk1.6.0_10/jre    PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin    CLASSPATH=.:$JAVA_HOME/lib/jt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib    export JAVA_HOME JRE_HOME PATH CLASSPATH

Note: the preceding.: And Linux, Number: number.
Add Complete Save exit
#source/etc/profile

Uninstalling and installing the JDK on Linux

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.