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
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