Step 1: Download jdk-7-linux-i586.tar.gz
[Plain]
View plaincopy
- Http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.tar.gz wget-c
(Note: If the download fails, we recommend that you use thunder to download it and copy it to the Linux system .)
Step 2: unzip and install
[Plain]
View plaincopy
- Sudo tar zxvf./jdk-7-linux-i586.tar.gz-C/usr/lib/jvm
- Cd/usr/lib/jvm
- Sudo mv jdk1.7.0/java-7-sun
Step 3: Modify Environment Variables
[Plain]
View plaincopy
- Vim ~ /. Bashrc
Add:[Plain]
View plaincopy
- Export JAVA_HOME =/usr/lib/jvm/java-7-sun
- Export JRE_HOME =$ {JAVA_HOME}/jre
- Export CLASSPATH =. :$ {JAVA_HOME}/lib :$ {JRE_HOME}/lib
- Export PATH =$ {JAVA_HOME}/bin: $ PATH
Save and exit. Enter the following command to make it take effect immediately.
[Plain]
View plaincopy
- Source ~ /. Bashrc
Step 4: configure the default JDK version
Ubuntu may have a default JDK, such as openjdk. To set the JDK we installed as the default JDK version, perform the following work.
Run the Code:[Plain]
View plaincopy
- Sudo update-alternatives -- install/usr/bin/java/usr/lib/jvm/java-7-sun/bin/java 300
- Sudo update-alternatives -- install/usr/bin/javac/usr/lib/jvm/java-7-sun/bin/javac 300
- Sudo update-alternatives -- install/usr/bin/jar/usr/lib/jvm/java-7-sun/bin/jar 300
- Sudo update-alternatives -- install/usr/bin/javah/usr/lib/jvm/java-7-sun/bin/javah 300
- Sudo update-alternatives -- install/usr/bin/javap/usr/lib/jvm/java-7-sun/bin/javap 300
Run the Code:[Plain]
View plaincopy
- Sudo update-alternatives -- config java
JDK versions are listed as follows:[Plain]
View plaincopy
- Snowdream @ snowdream :~ $ Sudo update-alternatives -- config java
- Three candidate items can be used to replace java (/usr/bin/java ).
- Select the path priority status
- ------------------------------------------------------------
- * 0/usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 automatic mode
- 1/usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode
- 2/usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode
- 3/usr/lib/jvm/java-7-sun/bin/java 300 manual mode
- To maintain the current value [*], press the Enter key or enter the selected number: 3
- Update-alternatives:/usr/lib/jvm/java-7-sun/bin/java is used to provide/usr/bin/java (java) in manual mode.
Step 5: Test
[Plain]
View plaincopy
- Snowdream @ snowdream :~ $ Java-version
- Java version "1.7.0"
- Java (TM) SE Runtime Environment (build 1.7.0-b147)
- Java HotSpot (TM) Server VM (build 21.0-b17, mixed mode)
Reference link:
1. Install JDK configuration Eclipse and Tomcat under Ubuntu 10.10 [reprint + correction] http://www.cnblogs.com/evasnowind/archive/2011/01/05/1926059.html
2, ubuntu jdk installation process (for reference only) http://forum.ubuntu.org.cn/viewtopic.php? T = 183803
3, java learning jdk installation http://www.cnblogs.com/shaoguobao/archive/2011/07/16/2108015.html