卸载OpenJDK:
[root@WX32 local]# java -version
java version "1.6.0"
OpenJDK  Runtime Environment (build 1.6.0-b09)
OpenJDK 64-Bit Server VM (build 1.6.0-b09, mixed mode)

[root@WX32 local]# rpm -qa | grep java
java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5
java-1.4.2-gcj-compat-1.4.2.0-40jpp.115

[root@WX32 local]# rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5
[root@WX32 local]# rpm -e --nodeps java-1.4.2-gcj-compat-1.4.2.0-40jpp.115

[root@WX32 local]# java -version
-bash: /usr/bin/java: No such file or directory

安装SunJDK:
[root@WX32 local]# mkdir java
[root@WX32 local]# cd java/
[root@WX32 java]# pwd
/usr/local/java
[root@WX32 java]# wget http://download.oracle.com/otn/java/jdk/6u45-b06/jdk-6u45-linux-i586.bin
[root@WX32 java]# chmod +x jdk-6u45-linux-i586.bin
[root@WX32 java]# ./jdk-6u45-linux-i586.bin

解压安装包后,配置环境变量:
[root@WX32 java]# vi /etc/profile

在文件最后一行添加(注意安装路径):
JAVA_HOME=/usr/local/java/jdk1.6.0_45
JRE_HOME=/usr/local/java/jdk1.6.0_45/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

保存退出后,使其生效后即可:
[root@WX32 java]# source /etc/profile
[root@WX32 java]# java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) Server VM (build 20.45-b01, mixed mode)