Http://blog.chinaunix.net/u/21684/showart_384208.html
1. Manually install JDK 6
First, download the http://java.sun.com in the jdk-6u12-linux-i586.bin, it is said that this operation is relatively simple, do not need to switch.
Then, you can place it in any folder you like. If you are a cainiao like me, it is recommended to put it under the main folder (/home.
Install JDK as follows:
Enter your jdk-6u12-linux-i586.bin under the terminal, for example, my location is:/home/liangshihong
Change the File Permission to Executable
$ Sudo chmod U + x jdk-6u12-linux-i586.bin
$ Sudo-S./jdk-6u12-linux-i586.bin
Press enter until you are asked whether to install it. Enter yes and press Enter.
OK. After the installation is complete, configure the environment variables below.
Configure classpath and modify the environment variables of all users
$ Sudo gedit/etc/profile
Add at the end of the file
# Set Java environment
Java_home =/home/liangshihong/jdk1.6.0 _ 12
Export jre_home =/home/liangshihong/jdk1.6.0 _ 12/JRE
Export classpath =.: $ java_home/lib: $ jre_home/lib: $ classpath
Export Path = $ java_home/bin: $ jre_home/bin: $ path
Restart the computer and run the command to test the JDK version.
Java-version
The following information is displayed: the installation is successful.
Java version "1.6.0 _ 12"
Java (TM) se Runtime Environment (build 1.6.0 _ 12-b04)
Java hotspot (TM) server VM (build 11.2-b01, mixed mode)
2. Solution to the error:
After JDK is installed, this error occurs after environment variables are set:
[Root @ localhost lib] # javac
Error occurred during initialization of VM
Java/lang/noclassdeffounderror: Java/lang/Object
[Root @ localhost lib] # Java
Error occurred during initialization of VM
Java/lang/noclassdeffounderror: Java/lang/Object Solution: /Opt/jdk1.6.0 _ 15/lib/tools. Pack to convert to tools. Jar /Opt/jdk1.6.0 _ 15/JRE/lib/RT. Pack to Rt. Jar [Root @ localhost lib] # pwd
/Opt/jdk1.6.0 _ 15/lib
[Root @ localhost lib] # unpack200 tools. Pack tools. Jar
[Root @ localhost lib] # ls
Ct. sym htmlconverter. Jar jconsole. Jar orb. IDL tools. Jar tools. Pack. Bak
DT. Jar IR. IDL jexec sa-jdi.jar tools. Pack visualvm [Root @ localhost lib] # pwd
/Opt/jdk1.6.0 _ 15/JRE/lib
[Root @ localhost lib] # unpack200 rt. Pack Rt. Jar