简体   繁体   English

在 Mac OS X Lion 中初始化 Java VM 时出错

[英]Error initializing Java VM in Mac OS X Lion

I am having an issue getting my Java to work on Mac OS X Lion.我的 Java 在 Mac OS X Lion 上运行时遇到问题。 I did the Java upgrade where it completly removed it.我做了 Java 升级,它完全删除了它。 Then I needed it again, and I did an install of 7v9.apps that didn't work.然后我又需要它了,我安装了 7v9.apps,但没有用。

I then did the Apple KB (knowledge-base) article of reverting it back to 6, but that didn't work.然后我做了 Apple KB(知识库)文章,将其恢复为 6,但这没有用。 I uninstalled it completely (many times now), and reinstall 7v9, but I can't get my apps to work nor can I get the java console to open.我完全卸载了它(现在很多次),然后重新安装 7v9,但我无法让我的应用程序工作,也无法打开 Java 控制台。

Can anyone help?任何人都可以帮忙吗? Here are my logs from the console:这是我从控制台获取的日志:

10/31/12 3:01:44.681 PM [0x0-0x6ea6ea].com.apple.systempreferences: /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/jcontrol: line 116: [: too many arguments

10/31/12 3:01:44.681 PM [0x0-0x6ea6ea].com.apple.systempreferences: /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/jcontrol: line 120: [: -Xdock:icon=/Library/Internet: binary operator expected

10/31/12 3:01:44.723 PM [0x0-0x6ea6ea].com.apple.systempreferences: Error occurred during initialization of VM

10/31/12 3:01:44.723 PM [0x0-0x6ea6ea].com.apple.systempreferences: java.lang.NullPointerException

10/31/12 3:01:44.723 PM [0x0-0x6ea6ea].com.apple.systempreferences:     at java.util.Hashtable.put(Hashtable.java:542)

10/31/12 3:01:44.723 PM [0x0-0x6ea6ea].com.apple.systempreferences:     at java.lang.System.initProperties(Native Method)

10/31/12 3:01:44.723 PM [0x0-0x6ea6ea].com.apple.systempreferences:     at java.lang.System.initializeSystemClass(System.java:1115)
[…]/jcontrol: line 116: [: too many arguments […]/jcontrol: line 120: [: -Xdock:icon=/Library/Internet: binary operator expected

It looks like there were syntax errors in that jcontrol file, which manifest themselves because some ancestor process set environment variables _JCP_DOCK_NAME and _JCP_DOCK_ICON .看起来该jcontrol文件中存在语法错误,这表明它们是因为某些祖先进程设置了环境变量_JCP_DOCK_NAME_JCP_DOCK_ICON The output of env | grep JCP env | grep JCP的输出env | grep JCP env | grep JCP might be useful here. env | grep JCP在这里可能有用。 The jcontrol script can be fixed by adding quotes around these variables in the mentioned lines:可以通过在上述行中的这些变量周围添加引号来修复jcontrol脚本:

if [ -z "${_JCP_DOCK_NAME}" ]; then
    _JCP_DOCK_NAME=-Xdock:name="Java Control Panel"
fi

if [ -z "${_JCP_DOCK_ICON}" ]; then
    _JCP_DOCK_ICON=-Xdock:icon="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Resources/Java7VM.icns"
fi

I'm far from sure whether this is the cause of the subsequent error messages, though.不过,我不确定这是否是后续错误消息的原因。

 Error occurred during initialization of VM java.lang.NullPointerException at java.util.Hashtable.put(Hashtable.java:542) at java.lang.System.initProperties(Native Method) at java.lang.System.initializeSystemClass(System.java:1115)

Hashtable.put throws a null pointer exception if the value argument is null .如果value参数为nullHashtable.put会引发空指针异常。 It would have been interesting to know what key this is referring to, but the Java debugger probably won't be of much use when debugging this native code .知道这指的是什么键会很有趣,但 Java 调试器在调试此本机代码时可能没有多大用处。 Perhaps your best bet is to use a general application debugger like "gdb" in an attempt to figure out the key associated with the null value in that put call.也许您最好的选择是使用像“gdb”这样的通用应用程序调试器来尝试找出与该put调用中的null值关联的键。

/Library/Internet: binary operator expected

I had a similar error when trying to use Oracle JDeveloper on OS X.我在 OS X 上尝试使用Oracle JDeveloper时遇到了类似的错误。

I think the problem is the space in $JAVA_HOME environment variable.我认为问题在于$JAVA_HOME环境变量中的空间。 I simply made a symlink to the location of Oracle Java 1.7:我只是做了一个指向 Oracle Java 1.7 位置的符号链接:

>ls -la /usr/local/oraclejava
lrwxr-xr-x  1 root  admin  64 20 Sep 13:33 /usr/local/oraclejava -> /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

Re-launching the app after setting $JAVA_HOME to /usr/local/oraclejava fixed the problem.$JAVA_HOME/usr/local/oraclejava后重新启动应用程序修复了该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM