1 environment
Ubuntu 12.04 32-bit system in VMware virtual machines
2 Specific installation steps
① Download the latest JDK package
Note that the JDK distinguishes between 32-bit and 64-bit versions and is compatible with Ubuntu.
Http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
② Create a directory, unzip the Tarball
mkdir USR/LIB/JVM
Move to the directory, and unzip
[Email protected]:/usr/lib$ sudo mv jdk-7u65-linux-x64.tar.gz./JVM
Extract
Tar zvxf jdk-7u65-linux-x64.tar.gz./JVM
③ Setting Environment variables
Edit the. Profile file
It's a good idea to back up your profile before you edit it
[Email protected]:/$ cp ~/.profile ~/.profile_original
Open profile file sudo vim ~/.profile
Add the following command at the end of the. Profile file
Export java_home=/usr/lib/jvm/jdk1.7.0_65
Execute the following command at the terminal to make the modified configuration effective immediately:
SOURCE ~/.profile
Modify the system default JDK.
sudo update-alternatives--install/usr/bin/java Java/usr/lib/jvm/jdk1.7.0_65/bin/java 300
The results shown are as follows:
Modifying the Javac configuration
Effects such as
Then update the operation separately:
$ sudo update-alternatives--config java $ sudo update-alternatives--config javac
④ test whether the installation was successful
Then enter java-version and see the following information to change to the Sun's JDK:
⑤ issues that may be encountered
The following information is displayed when the validation is successful:
The reason: The JDK is 64-bit, and the operating system is 32-bit, does not match
The relationship of the JDK version
x86--32-bit x64--64 bit
When downloading, be sure to note whether it is 32-bit or 64-bit, to match your own system
⑥ Reference Articles
1 Blog Park, how to install JDK under Linux, take Ubuntu as an example
2 Blog Park, Ubuntu 12.04 Install and configure Java JDK
3 Ubuntu Forum, Ubuntu input Java command Prompt Unable to execute binary file