Step 1: Download jdkhttp: // response
Step 1: Download jdk
Http://www.oracle.com/technetwork/java/javase/downloads/index.html
Step 2: unzip and install
Go to the directory where the file is located and execute sudo tar zxvf jdk-7-linux-i586.tar.gz-C/usr/lib/jvm
Decompress the package to/usr/lib/jvm.
Step 3: Modify Environment Variables
Sudo gedit/etc/environment
PATH = "......:/usr/lib/jvm/java/jdk1.6.0 _ 12/bin"
CLASSPATH =.:/usr/lib/jvm/java/jdk1.6.0 _ 12/lib
JAVA_HOME =/usr/lib/jvm/java/jdk1.6.0 _ 12
Save and exit. Enter the following command to make it take effect immediately
Source ~ /. Bashrc
Step 4: configure the default JDK version
Ubuntu may have a default JDK, such as openjdk. To set the installed JDK to the default JDK version, perform the following operations:
Sudo update-alternatives -- install/usr/bin/java/usr/lib/jvm/jdk7/bin/java 300
Sudo update-alternatives -- install/usr/bin/javac/usr/lib/jvm/jdk7/bin/javac 300
Sudo update-alternatives -- install/usr/bin/jar/usr/lib/jvm/jdk7/bin/jar 300
Run
Sudo update-alternatives -- config java
JDK versions are listed as follows:
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/jdk7/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/jdk7/bin/java is used to provide/usr/bin/java (java) in manual mode.
Step 5: Test
If java-version is executed and the corresponding version information is displayed, the configuration is successful.
For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2