2: Open the terminal in this directory, execute the following commands to execute the following commands under/usr/lib to create a new JDK decompression directory JVM:
[java] view plaincopy
sudo mkdir /usr/lib/jvm
3: Unzip the JDK file to/usr/lib/jvm directory:
[java] view plaincopy
sudo tar zxvf jdk-7u9-linux-i586.tar.gz -C /usr/lib/jvm
4: Set environment variables such as java_home and classpath:
[java] view plaincopy
sudo gedit /etc/environment
Add the following content under this file:
[java] view plaincopy
PATH=”/usr/lib/jvm/jdk1.7.0_09/bin”
JAVA_HOME=”/usr/lib/jvm/jdk1.7.0_09″
CLASSPATH=”.:/usr/lib/jvm/jdk1.7.0_09/lib”
5: If the PATH exists, use the colonary to separate the JDK BIN directory address. This way, the environment variables of the Java will be configured successfully, but the default JDK may not be installed by us because of Ubuntu, because Ubuntu There may also be the default JDK, such as OpenJDK; so in order to make the default use of the JDK we installed, the following commands need to be executed:
[java] view plaincopy
sudo update-alternatives –install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_09/bin/java 300
sudo update-alternatives –install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_09/bin/javac 300
sudo update-alternatives –config java
6: After the command is successfully executed, the JDK we installed is the system default. The execution command java -Version can successfully see the relevant information of JDK.
[java] view plaincopy
java version “1.7.0_09”
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) Client VM (build 23.5-b02, mixed mode)
[url]http://blog.csdn.net/scs2000/article/details/8546963[/url]