Method 1:
1. log on to the system as root
2. Go to java.sun.com to download the rpm for jdk1.5.0 for Linux. It should be a jdk-1_5_x-rc-linux-i586-rpm.bin File
3. Run the CHMOD + x jdk-1_5_x-rc-linux-i586-rpm.bin command to give it executable permissions
4. Install with rpm-IVH jdk-1_5_x-rc-linux-i586-rpm.bin
5. JDK is installed in the/usr/Java/directory.
6. Set environment variables (write to/etc/profile)
Export java_home =/usr/Java/jdk1.5
Export Path = $ path: $ java_home/bin: $ java_home/JRE/bin
Export classpath =.:/usr/Java/jdk1.5/lib:/usr/Java/jdk1.5/JRE/lib: $ classpath
Okay typed Java-version. If the JDK version information is displayed, it indicates that the JDK version is successful.
For the convenience of development, I made another Eclipse IDE, so that I can develop Java in Linux later.
Eclipse installation is much simpler. After downloading (a zip package), you can directly unzip it to the directory you want. I will decompress it to/OPT.
Method 2:
1. First download JDK (jdk-1_5_0_02-linux-i586.rpm) from the Internet, recommend Sun's official website www.sun.com, download and put it in the/home directory, of course, other places also do.
Go to the installation directory
# Cd/home
# Cp jdk-1_5_0_02-linux-i586.rpm/usr/local
# Cd/usr/local
Add executable permissions to all users
# Chmod + x jdk-1_5_0_02-linux-i586.rpm.bin
#./Jdk-1_5_0_02-linux-i586.rpm.bin
The file jdk-1_5_0_02-linux-i586.rpm is generated, and executable permissions are also added to all users
# Chmod + x jdk-1_5_0_02-linux-i586.rpm
InstallProgram
# Rpm-IVH jdk-1_5_0_02-linux-i586.rpm
If the installation protocol is displayed, press <enter>.
2. Set environment variables.
# Vi/etc/profile
Add at the end
# Set Java environment
Java_home =/usr/Java/jdk-1_5_0_02
Classpath =.: $ java_home/lib. Tools. Jar
Path = $ java_home/bin: $ path
Export java_home classpath path
Save and exit.
To enable JDK to be used by all users, you can:
VI/etc/profile. d/Java. Sh
Enter the following content in the new java. Sh file:
# Set Java environment
Java_home =/usr/Java/jdk-1_5_0_02
Classpath =.: $ java_home/lib. Tools. Jar
Path = $ java_home/bin: $ path
Export java_home classpath path
Save and exit, and then assign the permission to Java. sh: chmod 755/etc/profile. d/Java. Sh
3. Use the echo command on the terminal to check the environment variable settings.
# Echo $ java_home
# Echo $ classpath
# Echo $ path
4. Check whether JDK is successfully installed.
# Java-version
If you see the JVM version and related information, the installation is successful!