How to install Elasticsearch windows service on server with different versions of Java?

I have at least two versions of Java on server so JAVA_HOME points to version 8 not 11.

To start manually start ES I just modified elasticsearch-env.bat:

if "%JAVA_HOME%" == "" (
  set JAVA="%ES_HOME%\jdk\bin\java.exe"
  set JAVA_HOME="%ES_HOME%\jdk"
  set JAVA_TYPE=bundled jdk
) else (
  set JAVA="C:\Program Files\Java\jdk-11.0.6\bin\java.exe"
  set JAVA_TYPE=JAVA_HOME
)

But I cannot make it work for elasticsearch-service.bat
I modified several lines including '--Jvm' paramter but still does not work.
I tried set JAVA_HOME by adding line set "JAVA_HOME=C:\Program Files\Java\jdk-11.0.6" but it dost not work.

What should I modify to make it works?

Anyone can help?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.