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`