在OS X上使用Java 7和neo4j。

时间:2022-06-06 18:01:32

After upgrading Java to 7u45 in system preferences, Neo4j was still warning me about using the wrong version:

在系统首选项中升级Java到7u45之后,Neo4j仍然警告我使用错误的版本:

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

I want to use neo4j v2, which doesn't support Java 6, so I needed to fix this.

我想使用neo4j v2,它不支持Java 6,所以我需要解决这个问题。

2 个解决方案

#1


9  

I started a neo4j 1.9.4 server, and ran neo4j info. The output included this line:

我启动了一个neo4j 1.9.4服务器,并运行了neo4j信息。输出包括这一行:

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

So obviously, I needed to set JAVA_HOME. What to set it to? /usr/libexec/java_home returns that same directory. The JavaVirtualMachines directory doesn't include any other subfolders. So I tried exploring the java control panel (accessed from system preferences). Under the "Java" tab, click "View", and the path for 7u45 is given:

显然,我需要设置JAVA_HOME。要把它设置成什么?/usr/libexec/java_home返回相同的目录。javavirtualmachine目录不包含任何其他子文件夹。因此,我尝试探索java控制面板(从系统首选项访问)。在“Java”选项卡下,点击“View”,给出7u45的路径:

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

So I tried this, guessing 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.

That's no good.

那不是很好。

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

我搜索并找到了这个帖子,并在Lasse的建议中编辑了/ usr/local/cellar/neo4j/1.9.4 /libexec/bin/utils。我添加了两行:

 # 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 looks like the space in the path is confusing. I tried to escape it, 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 the simple (not necessarily nice) solution was just to make a symlink:

然后我决定简单的(不一定是好的)解决方法就是做一个符号链接:

$ 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 ran correctly; and I managed to upgrade to v2.0.0-M6 and it still worked.

此时,neo4j开始正确运行;我成功升级到v2.0.0-M6,它仍然有效。

#2


1  

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

您必须安装java JDK 1.7。x在你的Max OS上。

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

运行此操作以查看最新的java JDK在哪里。

$ /usr/libexec/java_home -V

美元/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

This case my latest version is 1.7.0_45

我的最新版本是1.7.0_45。

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

$ JAVA_HOME出口= /图书馆/ Java / Home / JavaVirtualMachines / jdk1.7.0_45.jdk /内容

$ bin/neo4j start

bin / neo4j美元开始

It works for me.

它适合我。

#1


9  

I started a neo4j 1.9.4 server, and ran neo4j info. The output included this line:

我启动了一个neo4j 1.9.4服务器,并运行了neo4j信息。输出包括这一行:

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

So obviously, I needed to set JAVA_HOME. What to set it to? /usr/libexec/java_home returns that same directory. The JavaVirtualMachines directory doesn't include any other subfolders. So I tried exploring the java control panel (accessed from system preferences). Under the "Java" tab, click "View", and the path for 7u45 is given:

显然,我需要设置JAVA_HOME。要把它设置成什么?/usr/libexec/java_home返回相同的目录。javavirtualmachine目录不包含任何其他子文件夹。因此,我尝试探索java控制面板(从系统首选项访问)。在“Java”选项卡下,点击“View”,给出7u45的路径:

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

So I tried this, guessing 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.

That's no good.

那不是很好。

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

我搜索并找到了这个帖子,并在Lasse的建议中编辑了/ usr/local/cellar/neo4j/1.9.4 /libexec/bin/utils。我添加了两行:

 # 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 looks like the space in the path is confusing. I tried to escape it, 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 the simple (not necessarily nice) solution was just to make a symlink:

然后我决定简单的(不一定是好的)解决方法就是做一个符号链接:

$ 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 ran correctly; and I managed to upgrade to v2.0.0-M6 and it still worked.

此时,neo4j开始正确运行;我成功升级到v2.0.0-M6,它仍然有效。

#2


1  

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

您必须安装java JDK 1.7。x在你的Max OS上。

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

运行此操作以查看最新的java JDK在哪里。

$ /usr/libexec/java_home -V

美元/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

This case my latest version is 1.7.0_45

我的最新版本是1.7.0_45。

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

$ JAVA_HOME出口= /图书馆/ Java / Home / JavaVirtualMachines / jdk1.7.0_45.jdk /内容

$ bin/neo4j start

bin / neo4j美元开始

It works for me.

它适合我。