CB-7044 Add JAVA_HOME when not set. Be stricter about ANDROID_HOME

Also switches to using the which module over shelljs.which (better
support for .bat files)