Step 1: Download jdk-7-linux-i586.tar.gz wget-chttp: // rewrite (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 sudota Step 1: Download jdk-7-linux-i586.tar.gz
- 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
- 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
- Vim ~ /. Bashrc
Add:
- 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.
- Source ~ /. Bashrc
Step 4: configure the default JDK version. Because Ubuntu may have a default JDK, such as openjdk, the following work is required to set the installed JDK to the default JDK version.
Run the Code:
- 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
Run the Code:
- Sudo update-alternatives -- config java
JDK versions are listed as follows:
- Www.linuxidc.com @ linux :~ $ 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
- Www.linuxidc.com @ linux :~ $ 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)
Install JDK in Ubuntu 10.10 to configure Eclipse and Tomcat http://www.linuxidc.com/linux/2011-01/31367.htmjava_jdkinstall http://www.linuxidc.com/Linux/2011-08/40685.htm