There are many tutorials for installing JDK in Linux on the Internet, but we often download some incomplete tutorials on the Internet, which leads to environment configuration problems. I will share with you some of my company's configuration processes.
Operating System: Operating System of rat hat
JDK: jdk-6u18-linux-i586.rpm Please download the latest JDK version online
Step 1: uninstall the original jdk1.4.2 Operating System
Log on to the system as the root user and open a terminal input.
# Rpm-Qa | grep gcj
The displayed content contains the following two lines of information:
# Java-1.4.2-gcj-compat-1.4.2.0-27jpp
# Java-1.4.2-gcj-compat-devel-l.4.2.0-27jpp
Uninstall
# Rpm e java-1.4.2-gcj-compat-devel-l.4.2.0-27jpp
# Rpm e java-1.4.2-gcj-compat-l.4.2.0-27jpp
Displays a slightly different content for the uninstalled java-1.4.2-gcj, but does not affect the unload.
After the uninstallation is complete, enter Java-version to prompt that the Java command cannot be found;
Step 2: Install JDK
Put JDK in/home first
Installer
# Rpm-IVH jdk-6u18-linux-i586.rpm
If the installation protocol is displayed, simply accept it.
Install JDK in Linux Step 2. Set environment variables.
# Vi/etc/profile
Add at the end
# Set Java environment
Java_home =/usr/Java/jdk1.6.0 _ 18
Export java_home
Classpath =.: $ java_home/lib. Tools. Jar
Export classpath
Path = $ java_home/bin: $ path
Export path
Save and exit
(There are a few minor issues in many tutorials)
Add permissions to the profile.
Chmod + x/etc/profile
Execute Profile
Source/etc/profile
Set system variables (very important)
Set
After the command is executed, the set command prints the relevant system variables;
Check the JDK version:
Java-version