3

I have downloaded JDK and set the Path correctly, there are my outputs:

echo $JAVA_HOME
/home/me/Applications/jdk1.8.0_65

echo $PATH
/home/me/Applications/jdk1.8.0_65/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

java -version
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)

yet i get the problem below:

sudo /etc/init.d/elasticsearch start
Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME

Is there any problem with my Java installation, the files in the java bin directory are executable ?

Noor
  • 19,638
  • 38
  • 136
  • 254
  • Check where the init script looks for the Java executable – Marged Oct 21 '15 at 09:29
  • 4
    Environment variables don't propagate through `sudo`. This can be worked around, but if you want that startup script to work in real startup, you'll need to add those variables to the machine's global environment, or edit the script. – RealSkeptic Oct 21 '15 at 09:29

1 Answers1

5

Use sudo -E instead of sudo to propagate environment variables also.

dan
  • 13,132
  • 3
  • 38
  • 49