error running elasticsearch Java Could not find any executable java binary

I am unable to run elasticsearch when I run service elasticsearch start the ff below is what I did

[root@dc-lab05-06LVM ~]# export JAVA_HOME=/opt/jdk1.8.0_121/jre
[root@dc-lab05-06LVM ~]# echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/jdk1.8.0_121/bin/:confused: opt/jdk1.8.0_121/jre/bin:/root/bin
[root@dc-lab05-06LVM ~]# echo $JAVA_HOME
/opt/jdk1.8.0_121/jre
[root@dc-lab05-06LVM ~]# java -version
java version “1.8.0_121”
Java™ SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot™ 64-Bit Server VM (build 25.121-b13, mixed mode)
[root@dc-lab05-06LVM ~]# service elasticsearch start
Starting elasticsearch: which: no java in (/sbin:/usr/sbin:/bin:/usr/bin)
Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME
[FAILED]

I also tried adding this on my /etc/profile

export JRE_HOME=/opt/jdk1.8.0_121/jre

[root@dc-lab05-06LVM ~]# $PATH
-bash: /usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin: No such file or directory

Set the path to executable Java env to the PATH variable or you can set it up directly in ES startup script

I tried it on Java, but it fails with the same error message, can you please point to to which line number exactly on ES startup script(what exactly is the filename - I just want to be sure, I am just a newbie on this arena). I appreciate your help.

https://www.elastic.co/guide/en/elasticsearch/reference/current/setup.html

This is very good guide sir! :smiley: , I will have to reinstall again, strange I was able to install JDK 1.8.0_121 on our cloud, but know having some troible getting it to work on my local VM setup.. Thank you

I am still getting the same error even if I already changed to jdk1.8.0_131 rpm

Starting elasticsearch: which: no java in (/sbin:/usr/sbin:/bin:/usr/bin)
Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME
[FAILED]

It fails also when I install the update alternatives
alternatives --install /usr/bin/jar jar /usr/java/jdk1.8.0_131/bin/jar 2
alternatives --install /usr/bin/javac javac /usr/java/jdk1.8.0_131/bin/javac 2

Hi,

If you are playing with Elasticsearch this might be of interest:

http://genesysguru.com/blog/blog/2017/06/14/genesys-integration-on-the-wire-iotw/

That is an interesting article mate, I’ll get to that once I get past this.
I am still getting this error when I run service elasticsearch, but when I issue it from /usr/share/elasticsearch/bin I can execute elasticsearch with no problem the nodes all start up

genuser@c0n0_12 elasticsearch]# service elasticsearch start
Starting elasticsearch: which: no java in (/sbin:/usr/sbin:/bin:/usr/bin)
Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME
[FAILED]