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)