The problem of missing JAVA environment in ElasticSearch

When ubuntu configures ElasticSearch (I am using version 1.5 here), there is a problem that the java environment is missing.
Specifically, when starting the es service,

sudo /etc/init.d/elasticsearch startLater,

Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME

But there are already Java and JDK in the environment variables.

I found a solution to the problem, and gave a simple solution that I used.

Find the directory where your elasticsearch is executed, usually /etc/init.d/elasticsearch

Modify the elastisearch file, the permissions may not be enough, use chmod to change it.

then here

The first existing directory is used for JAVA_HOME (if JAVA_HOME is not defined in $DEFAULT)
JDK_DIRS="/usr/lib/jvm/java-8-oracle/ /usr/lib/jvm/j2sdk1.8-oracle/ /usr/lib/jvm/jdk-7-oracle-x64 /usr/lib/jvm/java-7-oracle /usr/lib/jvm/j2sdk1.7-oracle/ /usr/lib/jvm/java-7-openjdk /usr/lib/jvm/java-7-openjdk-amd64/ /usr/lib/jvm/java-7-openjdk-armhf /usr/lib/jvm/java-7-openjdk-i386/ /usr/lib/jvm/default-java"

Add your java root directory to this variable. For example, mine is /usr/lib/jvm/jdk1.8.0_65/

Then, modify and save. ok! After that you can start the service.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325878623&siteId=291194637