Install JDK 7 in CentOS

Source: Internet
Author: User
Install JDK 7 in CentOS

 

: Http://www.oracle.com/technetwork/java/javase/downloads/java-se-jdk-7-download-432154.html

1. Install JDK1.7.0
After the download is complete, run the following command after obtaining the root permission:

[Root @ sea] # sudo rpm-ivh/directories/jdk-7-linux-x64.rpm

 

Execution result:

Preparing... ################################### [100%]1:jdk ##################################### [100%]Unpacking JAR files... rt.jar... jsse.jar... charsets.jar... tools.jar... localedata.jar... 

 

2. Set Environment Variables

Here we need to find the profile file and add the environment variable: # vim/etc/profile append the following information under the profile file: export JAVA_HOME =/usr/java/jdk1.7.0export CLASSPATH =.: $ JAVA_HOME/jre/lib/rt. jar: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jarexport PATH = $ PATH: $ JAVA_HOME/bin save and exit. Run: # source/etc/profile

 

3. Update alternatives and select the JDK version.
You can use # Java-version to check whether the JDK version is 6.0. In this case, we need to select JDK 7 installed on the local machine.

First install java alternative --- jdk # update-alternatives -- install/usr/bin/java/usr/java/jdk1.7.0/bin/java 60 and then configure JDK: # update-alternatives -- config java

 

The following prompt appears:
A total of three programs provide "java ".
Select command
-----------------------------------------------

*+ 1 /usr/lib/jvm/jre-1.6.0-openjdk/bin/java2 /usr/lib/jvm/jre-1.5.0-gcj/bin/java3 /usr/java/jdk1.7.0/bin/java

 

Select/usr/java/jdk1.7.0/bin/java
// Press Enter to save the current selection [+], or type the selection number: 3

Install JDK 7 in CentOS 6.0. Check out your JDK version.

# java -versionjava version "1.7.0"Java(TM) SE Runtime Environment (build 1.7.0-b147)Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode, sharing)
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.