You have to set the JAVA_HOME environment variable prior to installing ElasticSearch. Otherwise, the message “JAVA_HOME environment variable must be set!” will be displayed during the installation. This document explains the steps to be taken to set the JAVA_HOME environment variable.
Java Virtual Machine or OpenJDK (version 11) has to be installed on the machine that runs the ElasticSearch engine. To set the JAVA_HOME environment variable, follow these steps:
Note: For ElasticSearch version 7.17.0 and above, use the variable name ES_JAVA_HOME instead.