Failed to start elasticsearch 7.0 from service

Hi all. I' m trying to start elasticsearch from service following this instruction.
https://www.elastic.co/guide/en/elasticsearch/reference/7.0/starting-elasticsearch.html
I cannot start elasticsearch.
Cannot find java even though PATH and JAVA_HOME are set.

How can i fix this ?

user1@ubuntu-trusty-1:~$ sudo -i service elasticsearch start
Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME

user1@ubuntu-trusty-1:~$ su -
Password: 

root@ubuntu-trusty-1:~# echo $JAVA_HOME
/opt/jdk-11.0.2

root@ubuntu-trusty-1:~# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/jdk-11.0.2/bin

root@ubuntu-trusty-1:~# java -version
openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)

root@ubuntu-trusty-1:~# which java
/opt/jdk-11.0.2/bin/java

The service is not using the root user to run.

Thank you very much to taking your time.
I'm not familiar with Ubuntu. How can I fix this.
By editting /etc/environment is correct ?

Not familiar either. But in 7.0 you don't normally need to provide a jvm yourself.
So I'd just try to follow the installation guide, step by step.

May be someone else can help though.

@dadoonet @yama2k
Same issue being faced by me also
I tried to download as a tar

@shrikantgulia
Thank you for additional information.
in my case, installed with apt-get.

@dadoonet @shrikantgulia
Thank you very much. I resolved it by own.

I installed Elasticsearch by apt-get, but installed java by tar.
That's the reason why I faced to this issue.
By installing java by apt-get was the way to resolve.
Thank you.

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