This article is reproduced! Please refer to the original! Add your own parts to the changes!
1, to the official website download JDK7, find jdk-7u21-linux-i586.tar.gz and download: http://www.oracle.com/technetwork/java/javase/downloads/ Jdk7-downloads-1880260.html
2. After extracting the folder named Jdk1.7.0_21, copy it to/USR/LIB/JVM (new JVM folder is required).
3. Configure the JDK environment variables:
When you start the terminal and enter
Gedit/etc/profile
Add the configuration at the end, save and exit
#set JDK Environment export java_home=/usr/lib/jvm/jdk1.7.0_21 export classpath=.: $JAVA _home/lib: $JAVA _ Home/jre/lib: $CLASSPATH export path= $JAVA _home/bin: $JAVA _home/jre/bin: $PATH
Terminal input command to make configuration effective
Source/etc/profile
4. See if the configuration is successful. In the terminal input
Java-version
If the display version is 1.7.0.21, the configuration succeeds, as shown below:
Java version "1.7.0_21" Java (tm) SE Runtime Environment (build 1.7.0_21-b11) Java HotSpot (tm) Server VM (build 23. 21-B01, Mixed mode)
If the display is still OPENJDK, perform step 5, test again
5, configure default Jdk,ubuntu under Default JDK is OPENJDK. Terminal input
sudo update-alternatives--install/usr/lib/java java/usr/lib/jvm/jdk1.7.0_17/bin/java sudo Update-alternatives--install/usr/lib/javac Javac/usr/lib/jvm/jdk1.7.0_17/bin/javac 300
Execute the following command to configure the default JDK
sudo update-alternatives--config java
The JDK version is listed, which is labeled "*" as the default JDK. If you want to maintain the current default JDK, press ENTER directly, otherwise enter the number of the corresponding JDK to set it as the default version.
Ubuntu Configuration JDK Environment variables