Search code examples
ubuntuneo4jjava-home

neo4j console does not start. ERROR: JAVA_HOME is incorrectly defined


When I start neo4j console or neo4j-shell I get this error:

ERROR: JAVA_HOME is incorrectly defined as /usr/lib/jvm/java-8-oracle/jre/bin/java (the executable /usr/lib/jvm/java-8-oracle/jre/bin/java/bin/java does not exist)

On echo $JAVA_HOME I get:

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

This is my settings in ~/.bashrc:

JAVA_HOME=/usr/lib/jvm/java-8-oracle/jre/bin/java
export JAVA_HOME

PATH=$PATH:$JAVA_HOME
export PATH

I have checked and tried all solutions on similar questions here and nothing worked. I am running Ubuntu 18.04.1 LTS, and the neo4j community-3.5.0-rc01. I heve also tried on other neo4j versions.


Solution

  • Notice the error at the end reads jre/bin/java/bin/java. Notice the double bin/java. You need to remove bin/java from JAVA_HOME=/usr/lib/jvm/java-8-oracle/jre/bin/java. Java knows the layout of the files so it knows that bin/java will be below JAVA_HOME and you don't need to give it.