RHEL alternatives for a new java environment

To add a new alternative for java execute following commands. Current system is CentOS 4.8 x86 Linux.

# alternatives --install /usr/bin/java java /opt/IBMJava2-142/jre/bin/java 100 
--slave /usr/lib/jvm/jre jre /opt/IBMJava2-142/jre 
--slave /usr/lib/jvm/jre-1.4.2 jre-1.4.2 /opt/IBMJava2-142/jre 
--slave /usr/bin/rmiregistry rmiregistry /opt/IBMJava2-142/jre/bin/rmiregistry

# alternatives --config java
There are 2 programs which provide 'java'.
 Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.4.2-gcj/bin/java
   2           /opt/IBMJava2-142/jre/bin/java

Enter to keep the current selection[+], or type selection number: 2

In case of the IBM JRE you need to override the symbolic links for /usr/bin/java and /usr/bin/rmiregistry. Otherwise the java executives cannot locate required libs under /opt/IBMJava2-142/jre/bin/classic. This is not required for other JREs for example Oracle/Sun JRE.

# ln -s /opt/IBMJava2-142/jre/bin/java /usr/bin/java
# ln -s /opt/IBMJava2-142/jre/bin/rmiregistry /usr/bin/rmiregistry

I modified the /etc/profile and added the environment variable JAVA_HOME.

Done!