Upgrade to Ubuntu11.10, because the library does not have a sun-java6-jdk, you need to install. Therefore, I downloaded Java6u27 from the Oracle website (why not java7? Because there are not many software currently supported, and you can easily switch to Java7 if you really need it), then you can start to manually install it. First create a Java directory, and then extract the downloaded file to the directory: $ sudocpjdk-6u27-linux
After upgrading to Ubuntu 11.10, because there is no sun-java6-jdk in the library, you need to install it on your own. Therefore, I downloaded Java 6u27 from the Oracle website (why not Java 7? Because there are not many software currently supported, and you can easily switch to Java7 if you really need it), then you can start to manually install it.
First, create a Java directory and decompress the downloaded file to the directory:
- $ sudo cp jdk-6u27-linux-i586.bin /usr/lib/jvm
- $ cd /usr/lib/jvm
- $ sudo ./jdk-6u27-linux-i586.bin
- $ sudo mv jdk1.6.0_27/ java-1.6.0_27-sun/
- $ sudo ln -s java-1.6.0_27-sun java-6-sun
- $ sudo rm jdk-6u27-linux-i586.bin
Set the environment variables, including PATH, CLASSPATH, and JAVA_HOME. Note the bin directory added at the end of PATH:
- $ sudo vi /etc/environment
- PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/u
- sr/lib/jvm/java-6-sun/bin"
- CLASSPATH="/usr/lib/jvm/java-6-sun/lib"
- JAVA_HOME="/usr/lib/jvm/java-6-sun"
Then we want to tell the system that we are using sun's JDK, instead of OpenJDK:
- $ SudoUpdate-Alternatives-- Install/usr/bin/java/usr/lib/jvm/java-6-sun/bin/java 300
- $ SudoUpdate-Alternatives-- Install/usr/bin/javac/usr/lib/java-6-sun/bin/javac 300
- $ SudoUpdate-Alternatives-- Config java
- Two 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/bin/java 300 manual mode
To maintain the current value [*], press the Enter key or enter the selected number: 2
As shown above, you have set the java to be used. Finally, let's verify:
- $ java -version
- java version "1.6.0_27"
- Java(TM) SE Runtime Environment (build 1.6.0_27-b07)
- Java HotSpot(TM) Server VM (build 20.2-b06, mixed mode)
After finishing your work!