First of all, I am a newbie of Ubuntu. I have paid a lot for installing a JDK. In the end, I have successfully completed the installation, not my technical skills, it's not my luck. It's hard for me to see that I was not installed successfully. As a matter of fact, my installation was successful by relying entirely on someone else's blog [Appendix 1]. However, this blog has some flaws, so I decided to write a blog, to record the entire JDK installation process.
Installation environment
Host environment: Windows 7
Virtual Machine environment: Ubuntu 11.10
JDK: SUN jdk-6u30-linux-i586.bin under Linux X86
Procedure
1. Download JDK. Http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u30-download-1377139.html, select the jdk-6u30-linux-i586.bin under Linux X86, so that the direct use of thunder download, fast, put on the local machine.
Second, transfer the file to the Ubuntu system. The specific transfer method adopts the Network Neighbor method. For more information, see my other blog: http://www.cnblogs.com/breakmind/archive/2012/01/31/2332522.html.
Third: Open the terminal of Ubuntu 11.10. It is difficult to click and view the terminal of Ubuntu 11.10. I know there are two methods to enable the terminal of Ubuntu 11.10. 1. Shortcut Key: Ctrl + Atl + T. The three keys can be used together to open the terminal. 2. Click the Ubuntu icon (or Microsoft key) in the upper left corner and enter Terminal. The Terminal is displayed.
4. Execute the command line to implement the entire installation process. (Note that Ubuntu 11.10 has its own OpenJDK, which is a problem during the entire installation process)
First, copy the JDK to the specified directory, and decompress the copied file to the specified directory. The command line is as follows:
$ Sudo cp jdk-6u30-linux-i586.bin/usr/lib/jvm
$ Cd/usr/lib/jvm
$ Sudo./jdk-6u30-linux-i586.bin
$ Sudo mv jdk1.6.0 _ 30/java-1.6.0_30-sun/
$ Sudo ln-s java-1.6.0_30-sun java-6-sun
$ Sudo rm jdk-6u30-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:
$ Sudo update-alternatives -- install/usr/bin/java/usr/lib/jvm/java-6-sun/bin/java 300
$ Sudo update-alternatives -- install/usr/bin/javacjavac/usr/lib/jvm/java-6-sun/bin/javac 300
$ Sudo update-alternatives -- config java
The screen is displayed as follows:
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:
Input value: 2 press ENTER
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 phases 2-b06, mixed mode)
[Appendix 1]: My reference blog address: http://www.cnblogs.com/skyme/archive/2011/10/22/2221080.html