Be more defensive when using an external script to set JAVA_HOME.