# How to provide custom Java path without JAVA\_HOME or bundled JDK for service installation

**URL:** <https://discuss.elastic.co/t/how-to-provide-custom-java-path-without-java-home-or-bundled-jdk-for-service-installation/222309>\
**Category:** Elasticsearch\
**Created:** [March 5, 2020, 2:17pm UTC](https://discuss.elastic.co/t/how-to-provide-custom-java-path-without-java-home-or-bundled-jdk-for-service-installation/222309 "2020-03-05T14:17:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![antimatter](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@antimatter](https://discuss.elastic.co/u/antimatter)\
**Post date:** [March 5, 2020, 2:17pm UTC](https://discuss.elastic.co/t/how-to-provide-custom-java-path-without-java-home-or-bundled-jdk-for-service-installation/222309/1 "2020-03-05T14:17:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 2, 2020, 2:17pm UTC](https://discuss.elastic.co/t/how-to-provide-custom-java-path-without-java-home-or-bundled-jdk-for-service-installation/222309/2 "2020-04-02T14:17:39Z")

</div>

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