: 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.0
Export CLASSPATH =.: $ JAVA_HOME/jre/lib/rt. jar: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar
Export PATH = $ PATH: $ JAVA_HOME/bin
Save and exit. Execute:
# 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
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/java
2 /usr/lib/jvm/jre-1.5.0-gcj/bin/java
3 /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 -version
java 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)