3

I'm trying to run the neo4j server on an Ubuntu machine using this command:

sudo neo4j start

But it gives me this error:

ERROR: JAVA_HOME is incorrectly defined as /usr/lib/jvm/java-1.7.0-openjdk-amd64/bin/ (the executable /usr/lib/jvm/java-1.7.0-openjdk-amd64/bin//bin/java does not exist)

Now, I have set JAVA_HOME to the correct directory where Java is installed. Here is what I get when I run echo $JAVA_HOME:

/usr/lib/jvm/java-8-oracle

I don't know where it's getting that value for JAVA_HOME. I checked the configuration files but I couldn't find any variables referring to JAVA_HOME that I might need to set.

Benyamin Noori
  • 860
  • 1
  • 8
  • 24
  • Possible duplicate of: http://stackoverflow.com/questions/27319495/error-java-home-is-not-defined-correctly-executing-maven. Note the comment about ubuntu under the accepted answer. – cybersam Apr 04 '17 at 21:38

2 Answers2

4

It's the same problem with 7 and you can fix it like this:

JAVA_HOME should be set to the name of the directory that contains the bin directory that contains the Java executables (in particular, java itself).

Assuming you do have a /usr/lib/jvm/jdk1.7.0 directory, it probably contains a jre subdirectory that contains the bin directory that contains java and related executables.

So you should probably be setting JAVA_HOME to /usr/lib/jvm/jdk1.7.0/jre rather than /usr/lib/jvm/jdk1.7.0.

See JAVA_HOME is not defined correctly for more info.

tk421
  • 5,775
  • 6
  • 23
  • 34
1

Some distros, by default, reset your environment variables to ensure programs executed under root run as expected. (sudo: java: command not found after exiting from root user)

So keep environment variables when using sudo:

sudo -E neo4j start
ghchoi
  • 4,812
  • 4
  • 30
  • 53