Upgrade and installation of java (jdk) in linux

Source: Internet
Author: User

The following uses centos5.2 as an example to describe how to upgrade and install jdk.
The upgrade mainly involves modifying the paths of JAVA_HOME, CLASSPATH, and PATH. The specific process is as follows!

Download
Select the latest version,: http://java.sun.com/javase/downloads/widget/jdk6.jsp
There are two binary files





Java SE DevelopmentKit 6u18
650) this. width = 650; "src =" https://cds.sun.com/is-bin/intershop.static/WFS/CDS-CDS_Developer-Site/-/en_US/im/ic_download.gif "title =" linux <wbr> system java (jdk) upgrade install "border =" 0 "alt =" ic_download.gif "/> jdk-6u18-linux-x64-rpm.bin
76.62 MB

Java SE DevelopmentKit 6u18
650) this. width = 650; "src =" https://cds.sun.com/is-bin/intershop.static/WFS/CDS-CDS_Developer-Site/-/en_US/im/ic_download.gif "title =" linux <wbr> system java (jdk) upgrade install "border =" 0 "alt =" ic_download.gif "/> jdk-6u18-linux-x64.bin
80.87 MB


Run the binary file:

./Jdk-6u18-linux-x64-rpm.bin or./jdk-6u18-linux-x64.bin


The difference is: Generate rpm package and source package, rpm package with command rpm-ivh jdk-6u18-linux-i586-rpm.bin will be automatically installed under/usr/java, and. /The jdk1.6.0 _ 18 folder generated by the jdk-6u18-linux-i586.bin needs to be manually put in/usr/java or another custom directory.


In this example, select the next method to install, create a new java folder under/usr, copy the jdk-6u18-linux-x64.bin to/usr/java, enter/usr/java, execute permissions


Chmod + x dk-6u18-linux-x64.bin

Run the installation command

./Dk-6u18-linux-x64.bin


Note: install it in the root directory! After successful installation, the jdk 1.6.0 _ 18 directory is generated under the/usr Directory, which is the jdk installation directory.


JDK installation and configuration test environment CentOS ):

Use the java-version command to test the JDK version installed in the current system. If you select JAVA Development when installing the system, JDK is installed. Therefore, you need to delete the old version JDK1.4.

Run the rpm-qa | grepjdk and rpm-qa | grepgcj command to check the currently installed JDK version. Then run the command yum-y jdk according to the displayed version, press enter to automatically delete the currently installed JDK.-bash:/usr/bin/java: No such file ordirectory will appear when java-version is used again, after detection, you can install the new JDK.


Of course, you may or may not configure it according to the above requirements. The following will be a detailed introduction!

There are two options for Configuration:

1. directly edit the/etc/profile file at the end of the file ).

2. Create a file under the/etc/profile. d directory.

Set the environment variables as follows:

# Setjava

JAVA_HOME =/usr/java/jdk1.6.0 _ 18

PATH = $ PATH:/$ JAVA_HOME/bin

CLASSPATH =.: $ JAVA_HOME/lib

JRE_HOME = $ JAVA_HOME/jre

Export JAVA_HOME PATH CLASSPATHJRE_HOME

Note:/usr/java/jdk1.6.0 _ 18 is the JDK path.

This example uses a configuration;

Vi/etc/profile:

# Setjava

JAVA_HOME =/usr/java/jdk1.6.0 _ 18

PATH = $ PATH:/$ JAVA_HOME/bin

CLASSPATH =.: $ JAVA_HOME/lib

JRE_HOME = $ JAVA_HOME/jre

Export JAVA_HOME PATH CLASSPATHJRE_HOME

Save and exit. Run # source/etc/profile, which takes effect immediately.



Set the symbolic connection between java and javac


Find the java location:

$ Whichjava

/Usr/bin/java
Then mv/usr/bin/java. bak (replace the original java version with java. bak)


Ln-s-f/usr/java/jdk1.6.0 _ 18/jre/bin/java/usr/bin/java

Ln-s-f/usr/java/jdk1.6.0 _ 18/jre/bin/javac/usr/bin/javac


After you run java-version, the newly installed JDK version is displayed.

$ Java-version
Java version "1.6.0 _ 18"
Java (TM) SE RuntimeEnvironment (build 1.6.0 _ 18-b07)
Java HotSpot (TM) 64-BitServer VM (build 16.0-b13, mixedmode)

Upgrade successful!


This article is from the "ant nest" blog, please be sure to keep this source http://feihan21.blog.51cto.com/1364153/1303393

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.