1. Install JDK
Download JDK directly from Sun: The http://java.sun.com/j2se/1.4.2/download.html provides two downloads:
1. rpm in self-extracting file (j2sdk-1_4_2_04-linux-i586.bin, 32.77 MB) This is a self-extracting file, installed on Linux as follows:
# Chmod U + X./j2sdk-1_4_2_04-linux-i586.bin
#./J2sdk-1_4_2_04-linux-i586.bin
After entering YES as prompted, JDK is decompressed to The./j2sdk1.4.2 _ 04 directory. In order to be consistent with the JDK installation path in the following 2, we will perform the following operations to establish the installation path under/usr/Java and test the file to this path:
# Mkdir/usr/Java
# Cp-Fr./j2sdk1.4.2 _ 04/usr/Java
2. rpm in self-extracting file (j2sdk-1_4_2_04-linux-i586-rpm.bin, 32.77 MB) This is also a self-extracting file, but the extracted file is a j2sdk-1_4_2_04-linux-i586-rpm package, run the RPM command to install it on Linux. The installation is as follows:
# Chmod U + X./j2sdk-1_4_2_04-linux-i586-rpm.bin
#./J2sdk-1_4_2_04-linux-i586-rpm.bin
# Rpm-IVH j2sdk-1_4_2_04-linux-i586-rpm
The installation software automatically installs JDK in the/usr/Java/j2sdk1.4.2 _ 04 directory.
2. Configure Environment Variables
1. Modify user environment variables
Assume that the Java User is kunp. Edit the user's. bashrc file to set environment variables.
# Vi/home/kunp/. bashrc
Add the following to the. bashrc file:
Export java_home =/usr/Java/j2sdk1.4.2 _ 04
Export classpath = $ classpath: $ java_home/lib: $ java_home/JRE/lib
Export Path = $ java_home/bin: $ java_home/JRE/bin: $ path: $ homr/bin
2. Modify the environment variables of all users
# Vi/etc/profile
Add:
Export java_home =/usr/Java/j2sdk1.4.2 _ 04
Export classpath = $ classpath: $ java_home/lib: $ java_home/JRE/lib
Export Path = $ java_home/bin: $ java_home/JRE/bin: $ path: $ home/bin
If you log on as a root user, you only need to perform step 2, because it already contains the settings in step 1.
Another thing to note is that, after modification, if you want to test whether the machine is successful, you have to restart the machine once, therefore, the input of Java-version always prompts that the operation was unsuccessful, causing me to be depressed for a long time. Hey hey :})