Skip to content

Commit 5e68b63

Browse files
authored
Another fix for handling of paths on Windows
A previous fix for the handling of paths on Windows related to paths containing multiple spaces introduced a issue where if JAVA_HOME ends with a backslash, then Elasticsearch will refuse to start. This is not a critical bug as a workaround exists (remove the trailing backslash), but should be fixed nevertheless. This commit addresses this situation while not regressing the previous fix. Relates #22132
1 parent 61e1678 commit 5e68b63

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

distribution/src/main/resources/bin/elasticsearch-service.bat

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ SETLOCAL enabledelayedexpansion
44
TITLE Elasticsearch Service ${project.version}
55

66
IF DEFINED JAVA_HOME (
7-
SET JAVA="%JAVA_HOME%"\bin\java.exe
7+
SET JAVA="%JAVA_HOME%\bin\java.exe"
88
) ELSE (
99
FOR %%I IN (java.exe) DO set JAVA=%%~$PATH:I
1010
)
@@ -121,19 +121,19 @@ echo Installing service : "%SERVICE_ID%"
121121
echo Using JAVA_HOME (%ARCH%): "%JAVA_HOME%"
122122

123123
rem Check JVM server dll first
124-
if exist "%JAVA_HOME%"\jre\bin\server\jvm.dll (
124+
if exist "%JAVA_HOME%\jre\bin\server\jvm.dll" (
125125
set JVM_DLL=\jre\bin\server\jvm.dll
126126
goto foundJVM
127127
)
128128

129129
rem Check 'server' JRE (JRE installed on Windows Server)
130-
if exist "%JAVA_HOME%"\bin\server\jvm.dll (
130+
if exist "%JAVA_HOME%\bin\server\jvm.dll" (
131131
set JVM_DLL=\bin\server\jvm.dll
132132
goto foundJVM
133133
)
134134

135135
rem Fallback to 'client' JRE
136-
if exist "%JAVA_HOME%"\bin\client\jvm.dll (
136+
if exist "%JAVA_HOME%\bin\client\jvm.dll" (
137137
set JVM_DLL=\bin\client\jvm.dll
138138
echo Warning: JAVA_HOME points to a JRE and not JDK installation; a client (not a server^) JVM will be used...
139139
) else (

distribution/src/main/resources/bin/elasticsearch.in.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@echo off
22

33
IF DEFINED JAVA_HOME (
4-
set JAVA="%JAVA_HOME%"\bin\java.exe
4+
set JAVA="%JAVA_HOME%\bin\java.exe"
55
) ELSE (
66
FOR %%I IN (java.exe) DO set JAVA=%%~$PATH:I
77
)

0 commit comments

Comments
 (0)