# JAVA\_HOME and ES\_JAVA\_HOME

**URL:** <https://discuss.elastic.co/t/java-home-and-es-java-home/296651>\
**Category:** Elasticsearch\
**Created:** [February 8, 2022, 7:16pm UTC](https://discuss.elastic.co/t/java-home-and-es-java-home/296651 "2022-02-08T19:16:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![holobolo0815](https://avatars.discourse-cdn.com/v4/letter/h/ecc23a/32.png) [@holobolo0815](https://discuss.elastic.co/u/holobolo0815)\
**Post date:** [February 8, 2022, 7:16pm UTC](https://discuss.elastic.co/t/java-home-and-es-java-home/296651/1 "2022-02-08T19:16:59Z")

</div>

Hello,

As I understand JAVA\_HOME should _not_ be set, and ES\_JAVA\_HOME should _only be set if_ I want to use another JDK than the bundled one.

Alright, so my system just sets JAVA\_HOME for generic use and I don't care, and I would simply like to use ES\_JAVA\_HOME to point to the bundled JDK to be safe.

Where exactly do I define ES\_JAVA\_HOME?

I tried `/etc/sysconfig/elasticsearch`, and this seems to do fine for startup as a service of ES and some other commands.

However:

1. Even if setting ES\_JAVA\_HOME inside `/etc/sysconfig/elasticsearch` I still get the deprecation warning in some cases (but it's possible that it uses ES\_JAVA\_HOME nevertheless). This is because sysconfig is only sourced in `/usr/share/elasticsearch/bin/elasticsearch-env` after the deprecation warning.

```auto
# now set the path to java
if [! -z "$ES_JAVA_HOME"]; then
  JAVA="$ES_JAVA_HOME/bin/java"
  JAVA_TYPE="ES_JAVA_HOME"
elif [! -z "$JAVA_HOME"]; then
  # fallback to JAVA_HOME
  echo "warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME" >&2

...

source /etc/sysconfig/elasticsearch

```

1. Commands like `/usr/share/elasticsearch/bin/elasticsearch-certutil` do not seem to take setting ES\_JAVA\_HOME this way into account at all. They are not sourcing anything or using Elasticsearch-env for that matter.

Am I doing something wrong?

Thx.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [February 8, 2022, 9:46pm UTC](https://discuss.elastic.co/t/java-home-and-es-java-home/296651/2 "2022-02-08T21:46:08Z")

</div>

You'd usually set that as either a system wide variable, or one for a specific user.

[How to Set Environment Variables in Linux {Step-by-Step Guide}](https://phoenixnap.com/kb/linux-set-environment-variable) is an example of how to do that, but there's other examples out there.

---

<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:** [March 8, 2022, 9:46pm UTC](https://discuss.elastic.co/t/java-home-and-es-java-home/296651/3 "2022-03-08T21:46:20Z")

</div>

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