[FIXED JENKINS-25601] Amend JAVA_HOME check to work with JDK 9

This is completely untested. The PR build can help determine whether it works as expected though.