both output two different messages.
Error: JAVA_HOME is not defined correctly.
We cannot execute $JAVACMD
while batch says:
Error: JAVA_HOME not found in your environment.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
Same applies for M2_HOME. Additionally, testing for the Java command is handled different in both scripts. The batch script relies on JAVA_HOME while the shell script can ignore it. Both should require JAVA_HOME or warn about and use which java, respectively java in PATH (for %%X in (java.exe) do (set JAVACMD=%%~$PATH:X)) on Windows. After that should proceed to checking M2_HOME.