In Linux, uninstall the old JDK version and upgrade the new JDK version.

Source: Internet
Author: User
Tags html sample

Centos5.2 has its own JDK, but it is still in version 1.4. It is so old that Tomcat 6 is not running. Obviously, we cannot meet our requirements. Let's take a look, as shown below:

[root@localhost soft]# java -version
java version “1.4.2″
gij (GNU libgcj) version 4.1.2 20071124 (Red Hat 4.1.2-42)

Note: According to my installation in 5.2, it seems that the built-in 1.4 is not uninstalled, and the installation of JDK 6 cannot take effect. To avoid this problem, we first need to uninstall JDK 1.4.

[root@localhost soft]# rpm -qa | grep jdk
[root@localhost soft]# rpm -qa | grep gcj
libgcj-4.1.2-42.el5
java-1.4.2-gcj-compat-1.4.2.0-40jpp.115

First confirm the specific JDK version number, and then

[Root @ localhost jdk1.6.0 _ 11] # Yum-y remove java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
Setting up remove Process
Resolving dependencies ........... (Start to uninstall)
Removed: java-1.4.2-gcj-compat.i386. 4.2.0-40jpp. 115
Dependency removed: anlr. i386 0: 2. 7.6-4jpp. 2 BSF. i386 0: 2. 3.0-11jpp. 1 bsh. i386 0: 1. 3.0-9jpp. 1 gjdoc. i386 0: 0. 7.7-12. EL5 HSQLDB. i386 1:1. 8.0.9-1jpp. 2 OpenOffice.org-Calc. i386
. 3.0-container OpenOffice.org-core. i386. 3.0-container OpenOffice.org-draw. i386. 3.0-container OpenOffice.org-graphicfilter. i386. 3.0-6.5.el5 OpenOffice.org-impress. i386
. 3.0-6.5.el5 OpenOffice.org-langpack-zh_CN.i386. 3.0-6.5.el5 OpenOffice.org-langpack-zh_TW.i386. 3.0-6.5.el5 OpenOffice.org-math. i386. 3.0-6.5.el5 OpenOffice.org-
Writer. i386. 3.0-6.5.el5 OpenOffice.org-effectfilter. i386. 3.0-6.5.el5 tomcat5-jsp-2.0-api.i386. 5.23-0jpp. 7. EL5 tomcat5-servlet-2.4-api.i386. 5.23-0jpp. 7. EL5 xalan-
J2.i386. 7.0-6jpp. 1 xerces-j2.i386. 7.1-7jpp. 2 xml-commons-apis.i386. 3.02-0. b2.7jpp. 10 xml-commons-resolver.i386. 1-1jpp.12
Complete! (Uninstall completed)

The installation package I am using is a jdk-6u11-linux-i586.bin and does not use a general RPM package for the Red Hat platform.
First, upload the jdk-6u11-linux-i586.bin to/home/xjj/soft over ssh. Then, to give the jdk-6u11-linux-i586.bin
Assign permissions, specifically here to give it executable permissions, input: chmod + x jdk-6u11-linux-i586.bin, Here parameter x even if it has execution permissions.

[root@localhost soft]# chmod +x jdk-6u11-linux-i586.bin

Then unzip:./jdk-6u11-linux-i586.bin,

[root@localhost soft]# ./jdk-6u11-linux-i586.bin

After the execution, there will be a bunch of agreement or something, all the way more. Then there is a confirm installation, enter yes, and then press Enter. Start decompression. Until

Java(TM) SE Development Kit 6 successfully installed.
.........
Press Enter to continue.....
Done.

Look at the extracted files first

[root@localhost soft]# ls
jdk1.6.0_11 jdk-6u11-linux-i586.bin
[root@localhost soft]# cd jdk1.6.0_11
[root@localhost jdk1.6.0_11]# ls
bin db include lib man README_ja.html register.html register_zh_CN.html src.zip
COPYRIGHT demo jre LICENSE README.html README_zh_CN.html register_ja.html sample THIRDPARTYLICENSEREADME.txt

Haha, You can decompress what we are familiar. Generally, the installation file is stored in usr/local. Of course you can't take it if you don't. Therefore, run the Copy command first:

[root@localhost soft]# mv jdk1.6.0_11 /usr/local
Now, JDK has been successfully moved to/usr/local, and the last step is to set the environment variable. Two settings are available here. One is to temporarily take effect through the Export setting, and the setting will be lost after the restart, and the other is to write the settings to the/etc/profile file, which can always take effect. Therefore, the best setting is to write to the file. Run the following command:

[root@localhost jdk1.6.0_11]# vi /etc/profile

Open the profile file, enter I to enter insert mode, and add the following content to the file.

export JAVA_HOME=/usr/local/jdk1.6.0_11
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/rt.jar

Then run ESC, enter: X, save and exit. Then you need to set the change to take effect:

[root@localhost local]# source /etc/profile

Of course, if you like to restart, you can also reboot.

Let's take a look at the current JDK version:

[root@localhost local]# java -version
java version “1.6.0_11″
Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode, sharing)

Success!

 

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.