You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the javaDetect.bat script is run after a new CMD session is opened, the following error occurs:
Environment variable JAVA_VERSION not defined
To fix this error, the comment lines assigning to the JAVA_VERSION variable have been removed.
Click to see the code.
@ECHO OFF
SET __COMPAT_LAYER=RunAsInvoker
:: Export java settings from registry to a temporary file
START /W REGEDIT /E %Temp%\java.reg "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft"
IF NOT EXIST "%Temp%\java.reg" (
START /W REGEDIT /E %Temp%\java.reg "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft"
)
IF NOT EXIST "%Temp%\java.reg" (
ECHO Java NOT installed
EXIT /b 1
)
:: Find java location
FOR /F "tokens=1* delims==" %%A IN ('TYPE %Temp%\java.reg ^| FIND "INSTALLDIR"') DO SET JAVA_HOME=%%B
SET JAVA_HOME=%JAVA_HOME:"=%SET JAVA_HOME=%JAVA_HOME:\\=\%SET JAVA_HOME:: Get java versionFOR /F "tokens=1* delims==" %%A IN ('TYPE %Temp%\java.reg ^| FIND "CurrentVersion"') DO SET JAVA_VERSION=%%BSET JAVA_VERSION=%JAVA_VERSION:"=%
SET JAVA_VERSION
SET JAVA_VERSION=%JAVA_VERSION:.=%
SET JAVA_VERSION=%JAVA_VERSION:_=%
SET /A JAVA_VERSION=%JAVA_VERSION%
FOR /f tokens^=2-5^ delims^=.-_^" %%j in ('%JAVA_HOME%\bin\java.exe -fullversion 2^>^&1') do set "JAVA_VERSION=%%j%%k%%l%%m":: Delete temporary fileDEL %Temp%\java.reg /S /Q > NUL 2>&1set JAVA_VERSION:: Check java version compatibilityIF %JAVA_VERSION% LSS 16020 ( ECHO. ECHO YOU NEED AT LEAST JAVA WITH VERSION 1.6.0_20 -- this is just an example echo. GOTO :EOF)PAUSE
The text was updated successfully, but these errors were encountered:
When the javaDetect.bat script is run after a new CMD session is opened, the following error occurs:
To fix this error, the comment lines assigning to the
JAVA_VERSION
variable have been removed.Click to see the code.
The text was updated successfully, but these errors were encountered: