Automatically Setting JAVA_HOME on RHEL

Ever need to have JAVA_HOME set on RHEL, and find that it’s not?  Use these lines to set JAVA_HOME from you script file:

echo Setting JAVA_HOME to `alternatives --display java | head -2 | grep currently | awk '{print substr($0,27)}' | rev | cut -c 9- | rev`
export JAVA_HOME=`alternatives --display java | head -2 | grep currently | awk '{print substr($0,27)}' | rev | cut -c 9- | rev`
  • Ghostprogrammer
  • I am known for being able to quickly decipher difficult problems to assist development teams in producing a solution. I have been called upon to be the Team Lead for multiple large-scale projects. I have a keen interest in learning new technologies, always ready for a new challenge.

Leave a Comment

Your email address will not be published. Required fields are marked *

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

%d bloggers like this: