JAVA_HOME and ES_JAVA_HOME

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.
# 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.

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} is an example of how to do that, but there's other examples out there.

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