Using Java 7 with neo4j on OS X

After upgrading Java to 7u45 in the system settings, Neo4j still warned me about using the wrong version:

WARNING! You are using an unsupported Java runtime. Please use Oracle(R) Java(TM) Runtime Environment 7. 

I want to use neo4j v2 which does not support Java 6, so I needed to fix this.

+6
source share
2 answers

I started the neo4j 1.9.4 server and launched neo4j info . The output included this line:

 JAVA_HOME: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home 

Obviously, I needed to set JAVA_HOME. What is this to draw? /usr/libexec/java_home returns the same directory. The JavaVirtualMachines directory does not contain other subfolders. So I tried to learn the java control panel (access to it from the system settings). On the Java tab, click View, and the path for 7u45 will be indicated:

 /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java 

So, I tried this, suggesting that the Contents/Home directories were isomorphic:

 $ export JAVA_HOME=/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home $ neo4j start WARNING! You are using an unsupported Java runtime. Please use Oracle(R) Java(TM) Runtime Environment 7. Using additional JVM arguments: -server -XX:+DisableExplicitGC -Dorg.neo4j.server.properties=conf/neo4j-server.properties -Djava.util.logging.config.file=conf/logging.properties -Dlog4j.configuration=file:conf/log4j.properties -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -Dneo4j.ext.udc.source=homebrew Starting Neo4j Server...WARNING: not changing user process [34808]... waiting for server to be ready. Failed to start within 120 seconds. Neo4j Server may have failed to start, please check the logs. 

This is not good.

I searched and found this post , and on the advice of Lasse I edited /usr/local/Cellar/neo4j/1.9.4/libexec/bin/utils . I added two lines:

  # check if running Oracle JDK 7, warn if not checkjvmcompatibility() { + echo $JAVACMD + $JAVACMD -version $JAVACMD -version 2>&1 | egrep -q "Java HotSpot\\(TM\\) (64-Bit Server|Server|C lient) VM" if [ $? -eq 1 ] then echo "WARNING! You are using an unsupported Java runtime. Please use Oracle(R) Java(TM) Runtime Environment 7." else $JAVACMD -version 2>&1 | egrep -q "java version \"1.7" if [ $? -eq 1 ] then echo "WARNING! You are using an unsupported version of the Java runtime. Please use Oracle(R) Java(TM) Runtime Environment 7." fi fi } 

And tried again:

 $ neo4j start /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java bin/utils: line 349: /Library/Internet: No such file or directory WARNING! You are using an unsupported Java runtime. Please use Oracle(R) Java(TM) Runtime Environment 7. 

It seems like the space gap is messed up. I tried to escape, but my first approach failed:

 $ export JAVA_HOME="'/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home'" $ neo4j start Error: JAVA_HOME is not defined correctly. We cannot execute '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home'/bin/java 

And then I decided that a simple (not necessarily pleasant) solution was to make a symbolic link:

 $ cd /Library/ $ sudo ln -s Internet\ Plug-Ins/ Internet-Plug-Ins $ export JAVA_HOME=/Library/Internet-Plug-Ins/JavaAppletPlugin.plugin/Contents/Home 

At this point, neo4j start working correctly; and I managed to switch to v2.0.0-M6 and it still worked.

+9
source

You need to install java JDK 1.7.x on your Max OS and then

Run this to see where the latest java JDK is located.

$ / usr / libexec / java_home -V

 1.7.0_45, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home 1.6.0_65-b14-462, x86_64: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home 1.6.0_65-b14-462, i386: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home 

In this case, my latest version is 1.7.0_45

$ export JAVA_HOME = / Library / Java / JavaVirtualMachines / jdk1.7.0_45.jdk / Contents / Home

$ bin / neo4j start

This works for me.

+1
source

Source: https://habr.com/ru/post/957141/


All Articles