在系统偏好中将 Java 升级到 7u45 后,Neo4j 仍然警告我使用了错误的版本:
WARNING! You are using an unsupported Java runtime. Please use Oracle(R) Java(TM) Runtime Environment 7.
我想使用不支持 Java 6 的 neo4j v2,所以我需要解决这个问题。
我启动了一个 neo4j 1.9.4 服务器,然后运行neo4j info
. 输出包括这一行:
JAVA_HOME: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
很明显,我需要设置 JAVA_HOME。把它设置成什么?/usr/libexec/java_home
返回同一个目录。JavaVirtualMachines 目录不包含任何其他子文件夹。所以我尝试探索 java 控制面板(从系统首选项访问)。在“Java”选项卡下,点击“查看”,给出7u45的路径:
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
所以我尝试了这个,猜测Contents/Home
目录是同构的:
$ 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.
那不好。
我搜索并找到了这篇文章,并根据 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
}
并再次尝试:
$ 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.
看起来路径中的空间令人困惑。我试图逃避它,但我的第一种方法失败了:
$ 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
然后我决定简单(不一定很好)的解决方案就是创建一个符号链接:
$ cd /Library/
$ sudo ln -s Internet\ Plug-Ins/ Internet-Plug-Ins
$ export JAVA_HOME=/Library/Internet-Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
此时neo4j start
运行正确;我设法升级到 v2.0.0-M6 并且它仍然有效。
您必须在 Max OS 上安装 java JDK 1.7.x,然后
运行它来查看最新的 java JDK 在哪里。
$ /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
这个案例我的最新版本是1.7.0_45
$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home
$ bin/neo4j 开始
这个对我有用。