1. Download the Sun JDK file from the Oracle official website. I downloaded the jdk-6u22-linux-i586.bin.
2. Permission setting and Installation
I want to install JDK under the program directory for myself, copy the jdk-6u22-linux-i586.bin to/home/xuwei/Program
Run the CD command on the terminal to go to the/home/xuwei/Program/directory,
Then execute the command
Sudo chmod + x jdk-6u22-linux-i586.bin // Set permissions
Sudo./jdk-6u22-linux-i586.bin // execution File
PS: 2011-9-30
After reading other people installing JDK on the Internet, they all choose the/usr/Java directory. If you use the apt command to install JDK, install it in the/usr/lib/JVM/directory. Now I will run a manual command to copy JDK. bn to the/usr/lib/JVM directory, and install it through the above operations.
3. Configure Environment Variables
# Sudo gedit/etc/profile
Add at the end
# Set Java environment
Export java_home =/home/xuwei/Program/jdk1.6.0 _ 22
Export Path = $ java_home/bin: $ path
Export classpath =.: $ java_home/lib/tools. jar: $ java_home/lib/dt. jar: $ classpath
Save and exit.
4. log out and log on again (important. If this step is not completed, Echo cannot display the correct path and empty lines)
Run the echo command on the terminal to check the environment variable settings.
# Echo $ java_home
# Echo $ classpath
# Echo $ path
5. Check whether JDK is successfully installed.
# Java-version
Display:
Java version "1.6.0 _ 22"
Java (TM) se Runtime Environment (build 1.6.0 _ 22-b04)
Java hotspot (TM) server VM (build 17.1-b03, mixed mode)
If you see the JVM version and related information, the installation is successful!