Ext.: http://www.cnblogs.com/bluestorm/archive/2012/05/10/2493592.html
Go first.Oracle DownloadsLinux under the JDK compression package, I downloaded the jdk-7u4-linux-i586.tar.gz file, the next good after the direct decompression
STEP1:
# Copy the extracted jdk1.7.0_21 folder to the/USR/LIB/JVM directory with the highest permissions
sudo cp-r ~/jdk1.7.0_21//usr/lib/jvm/
STEP2:
# Configure Environment variables
sudo gedit/etc/profile
At the end add:
Export java_home=/usr/lib/jvm/jdk1.7.0_21
Then save the shutdown, using the source update under
$ source/etc/profile
Use the ENV command to see the value of Java_home
$ env
If java_home=/usr/lib/jvm/jdk1.7.0_21, the configuration is successful.
STEP3:
# Modify the system's default JDK.
$ sudo update-alternatives--install/usr/bin/java Java/usr/lib/jvm/jdk1.7.0_21/bin/java 300
Just enter the numbers in front of the sun JDK.
$ sudo update-alternatives--install/usr/bin/javac Javac/usr/lib/jvm/jdk1.7.0_21/bin/javac 300
$ sudo update-alternatives--config java
$ sudo update-alternatives--config javac
STEP4:
Then enter java-version and see the following information to change to the Sun's JDK:
Java Version "1.7.0_04"
Java (TM) SE Runtime Environment (build 1.7.0_04-b20)
Java HotSpot (TM) Server VM (build 23.0-b21, Mixed mode)
Problems that may exist:
1. Prompt missing libjli.so cannot start ..., the problem is that you download the JAVAJDK compression package is incomplete, or your decompression method is not the result, directly extracted to the current path, and then copied to the directory you need, the JDK installation directory can be arbitrarily selected, For example, you can put it in the home directory,
libjli.so file in: ~/jdk1.7.0_07/jre/lib/i386/jli/libjli.so
2. May not be configured successfully, need to uninstall the previously installed OPENJDK, can be removed from the command line
3. Different versions of the JDK, version number as modified can be
Installing and configuring Java JDK in Ubuntu 12.04