Minor improvement to JAVA_HOME calculation.