Skip to content

Commit

Permalink
chore(run): adjust java check to use assigned JAVA_HOME (#3958)
Browse files Browse the repository at this point in the history
and cover use case where JAVA_HOME contains empty space

related to #3907
  • Loading branch information
yanavasileva authored Dec 8, 2023
1 parent e925dce commit 51bc072
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions distro/run/assembly/resources/run.bat
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,18 @@ IF "x%JAVA_HOME%" == "x" (
GOTO :EOF
)
ECHO Setting JAVA property to "%JAVA_HOME%\bin\java"
SET JAVA="%JAVA_HOME%\bin\java"
SET "JAVA=%JAVA_HOME%\bin\java"
SET "RESTORE_PATH=%PATH%"
REM add temp the JAVA_HOME so this java is used in the java version check
SET "PATH=%JAVA_HOME%\bin;%PATH%"
)
)

SET EXPECTED_JAVA_VERSION=17
FOR /f "tokens=3" %%g IN ('JAVA -version 2^>^&1 ^| findstr /i "version"') DO (
FOR /f "tokens=3" %%g IN ('java -version 2^>^&1 ^| findstr /i "version"') DO (
SET JAVA_VERSION=%%g
)
REM Remove the surrounding quotes
SET JAVA_VERSION=%JAVA_VERSION:"=%
ECHO Java version is %JAVA_VERSION%
FOR /f "delims=. tokens=1" %%v in ("%JAVA_VERSION%") do (
Expand All @@ -50,6 +54,8 @@ FOR /f "delims=. tokens=1" %%v in ("%JAVA_VERSION%") do (
GOTO :EOF
)
)
REM revert PATH variable to its initial value
SET "PATH=%RESTORE_PATH%"

IF NOT "x%JAVA_OPTS%" == "x" (
ECHO JAVA_OPTS: %JAVA_OPTS%
Expand Down

0 comments on commit 51bc072

Please sign in to comment.