Note that it detects JAVA_HOME, but doesn't select that one. I would expect following the recommended path to just work. I have seen similar issues with ANDROID_SDK as well. I'm using version 1.11.14 ...
the script always echo 'java' should be on the PATH or JAVA_HOME must point to a valid JDK installation. so I echo "%JAVA_BIN%" everywhere and it was not changed ...