1. Uninstall the default JDK:
Log in to the system with the root user and open a terminal input
#rpm-qa | grep GCJ
Display content contains the following two lines of information
# java-1.4.2-gcj-compat-1.4.2.0 # java-1.4.2-gcj-compat-devel-l.4.2.0
Start uninstalling the JDK
# rpm -e java-1.4.2-gcj-compat-1.4.2.0# rpm -e java-1.4.2-gcj-compat-devel-l.4.2.0
Uninstall any other JDK you have installed and use RPM-E java-xxxx directly
2. Install the JDK:
Download JDK installation files Jdk-6u10-linux-i586-rpm.bin
Upload the Jdk-6u10-linux-i586-rpm.bin to the Linux server and execute the following command under the shell
#chmod 755 jdk-6u10-linux-i586-rpm.bin #./jdk-6u10-linux-i586-rpm.bin
There will be a sun agreement, a few times the space bar, when asked whether or not to agree, knock Yes.
The program will automatically generate a jdk-6u10-linux-i586-rpm.rpm file, which is the main package, which is installed below:
#rpm-IVH jdk-6u10-linux-i586-rpm.rpm (installed by default in/usr/java)
3. Set environment variables (. bashrc files):
Modify the. bashrc file in the user's home directory to add the JDK environment variable.
#vi .bashrc set JAVA_HOME=/usr/java/ export JAVA_HOME set PATH=$PATH:$JAVA_HOME/bin export PATH set CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export CLASSPATH #source ./bashrc
This can also be done by changing the/etc/profile, but it is not recommended because such a setting will be effective for all users ' shells and will have an impact on system security. Here's a check to see if the variable setting is in effect (logout before verification and then re-login). If you want a user to have permission to run Java commands, simply modify their bash initialization file.
Environment variable configuration (/etc/profile file):
#vi/etc/profile
In the profile file, add the following:
JAVA_HOME=/usr/java/jdk1.6.0_10 JRE_HOME=/usr/java/jdk1.6.0_10/jre PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin CLASSPATH=.:$JAVA_HOME/lib/jt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib export JAVA_HOME JRE_HOME PATH CLASSPATH
Note: the preceding.: And Linux, Number: number.
Add Complete Save exit
#source/etc/profile
Uninstalling and installing the JDK on Linux