[ll@ll-pc ~]$ ls /etc/profile.d/
glib2.csh jdk.csh jre.sh mozilla-common.csh xorg.csh
glib2.sh jdk.sh locale.sh mozilla-common.sh xorg.sh
gpm.sh jre.csh mercurial.sh perlbin.sh
[ll@ll-pc ~]$ cat /etc/profile.d/jdk.sh
export J2SDKDIR=/opt/java
export PATH=$PATH:/opt/java/bin:/opt/java/db/bin
export JAVA_HOME=/opt/java
export DERBY_HOME=/opt/java/db
[ll@ll-pc ~]$ cat /etc/profile.d/jre.sh
export PATH=$PATH:/opt/java/jre/bin
export JAVA_HOME=${JAVA_HOME:-/opt/java/jre}
做/opt/java到相应版本的软链就行。不用改别的什么。