set NMROOT=%cd%

rem get java version since it will be used to set the reflective-access flag
for /f tokens^=3 %%i in ('%JAVAHOME%\bin\java.exe -version 2^>^&1 ^| findstr /i "version"') do set java_version=%%i
for /f tokens^=1^ delims^=^". %%j in ('echo %java_version% 2^>^&1') do set java_version=%%j

rem java.util.logging keeps LogUtilites quiet. java.security keeps SSLUtilites quiet
if %java_version% lss 9 (
  set nm_reflective_access=
) else (
  set nm_reflective_access=--add-opens java.logging/java.util.logging=ALL-UNNAMED --add-opens java.base/java.security=ALL-UNNAMED
)

rem If the tools.jar exists, it is added, otherwise it is not
if exist "%JAVAHOME%\lib\tools.jar" (
  set nm_java_cmd="%NM_JAVA%" %NM_JVM_FLAGS% -classpath "%nm_boot_classpath%;%JAVAHOME%\lib\tools.jar"
  set nm_javac_cmd="%NM_JAVAC%" -g -Xlint %nm_sys_javac_flags% -classpath "%nm_boot_classpath%;%NMROOT%;%JAVAHOME%\lib\tools.jar"
) else (
  set nm_java_cmd="%NM_JAVA%" %NM_JVM_FLAGS% %nm_reflective_access% -classpath "%nm_boot_classpath%"
  set nm_javac_cmd="%NM_JAVAC%" -g -Xlint %nm_sys_javac_flags% -classpath "%nm_boot_classpath%;%NMROOT%"
)

%JAVAHOME%/bin/java -DNONATIVE=FALSE -DNMSTARTUP.USER=nxm.sys.test.custom_startup.mm -DNMPID=1234 -DNMROOT="classpath:" -Djava.library.path=%NMROOT%\jars %nm_reflective_access% -classpath %NMROOT%\jars\* nxm.sys.lib.NeXtMidas -path=SYS,DSP,UCL
