Installing new versions of Java on RHEL

RHEL includes the alternatives command providing the ability to point your users to different versions of software while not changing their links to the command.  For example if you wanted a specific version of JAVA this can be done with PATH changes or alternatives

man alternatives

for exact info.

For Java

/usr/sbin/alternatives --install /usr/bin/java java /location_to_new_java

/usr/sbin/alternatives --config java

Repeat for javac

Finally, set the environment for everyone on the machine by creating a java.sh script in /etc/profile.d:

#!/bin/sh
export JAVA_HOME=/usr/java/jdk
export JRE_HOME=$JAVA_HOME/jre
export J2RE_HOME=$JAVA_HOME/jre
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$J2RE_HOME/bin:$PATH

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.