First step: Download jdk-7-linux-i586.tar.gz
- Wget-c http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.tar.gz
(Note: If the download is not down, it is recommended to use Thunderbolt download, and then copied to the Linux system.) )
Step Two: Unzip the installation
- sudo MKDIR/USR/LIB/JVM
- sudo tar zxvf jdk-7u5-linux-x64.tar.gz-c/USR/LIB/JVM
Step Three: Modify environment variables
- sudo gedit/etc/profile
Add to:
- #set Java Environment
- 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 the exit and enter the following command to take effect immediately.
Fourth Step: Configure the default JDK version to set the JDK we installed as the default JDK version, do the following.
Execute code:
- sudo update-alternatives--install/usr/bin/java Java/usr/lib/jvm/java-7-sun/bin/java 300
- sudo update-alternatives--install/usr/bin/javac Javac/usr/lib/jvm/java-7-sun/bin/javac 300
Execute code:
- sudo update-alternatives--config java
The various JDK versions are listed as follows:
- [Email protected]:~$ sudo update-alternatives--config java
- There are 3 candidates that can be used to replace Java (providing/usr/bin/java).
- Select Path Priority state
- ------------------------------------------------------------
- * 0/usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 Auto 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 ENTER, or type the number of your choice: 3
- Update-alternatives: Use/usr/lib/jvm/java-7-sun/bin/java to provide/usr/bin/java (Java) in manual mode.
Fifth Step: Test
- Java-version (Displays the following information indicating that the configuration was successful)
- 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)
ubuntu12.04 Installation Configuration jdk1.7