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: Change the environment variables
- sudo gedit/etc/profile
Join:
- #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 exit. Enter the following command to make it effective immediately.
Fourth Step: Configure the default JDK version number to set the JDK we installed as the default JDK version number, for example, the following work.
To run the 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
To run the code:
- sudo update-alternatives--config java
The various JDK version numbers are listed, as seen below:
- < Span style= "margin:0px; padding:0px; Border:none; Background-color:inherit ">www.linuxidc.co[email protected]:~$ sudo update-alternatives -- config java
- There are 3 candidates that can be used to replace Java (providing/usr/bin/java).
-
-
- -- ----------------------------------------------------------
- * 0 /usr/lib/jvm/java-6-openjdk/jre /bin/java 1061 own active 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 (will show a demo sample such as 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 and Configuration jdk1.7