How to provide custom Java path without JAVA_HOME or bundled JDK for service installation

Hello,

I could not find answers regarding my issue by searching.

As far as I understand, Elasticsearch will look at JAVA_HOME environment variable to get the location of the JVM. If JAVA_HOME is not set, it will use the bundled JDK.

In our project both mechanisms are not viable. We have a software product that is shipped to Windows users as an Inno Setup installer and we already ship a recent JRE 8. This JRE is not installed and cannot be found on PATH nor is JAVA_HOME set. Now, we also include Elasticsearch in that product and set it up as a Windows service.

We want to use our already included JRE to be used by Elasticsearch, while not setting or changing any environment variables. The customer might use other Java software that depend on JAVA_HOME variable and changing it might break something. I can set JAVA_HOME in the installers code which only affects the installers environment but does not alter the system-wide JAVA_HOME variable. But the elasticsearch-service.bat will set the Java path for the service as %JAVA_HOME%\..., which is not the desired outcome.

I am not keen on modifying the *.bat files in the Elasticsearch\bin folder to meet these requirements. But a possible solution might be to directly call the "elasticsearch-service-x64.exe" (prunsrv.exe) with all the required parameters.

Is there a recommendation or a best practice for this situation?

Best,
Andreas

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