smarter JAVA_HOME setting