Ensure right java version is detected

If JAVA_HOME points to a different java than is on the path, then the
java version will be incorrectly detected.
Merge pull request #606 from jroper/java-version-cmd

Ensure right java version is detected