简体   繁体   中英

Error initializing Java VM in Mac OS X Lion

I am having an issue getting my Java to work on Mac OS X Lion. I did the Java upgrade where it completly removed it. Then I needed it again, and I did an install of 7v9.apps that didn't work.

I then did the Apple KB (knowledge-base) article of reverting it back to 6, but that didn't work. 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.

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 . The output of env | grep JCP env | grep JCP might be useful here. The jcontrol script can be fixed by adding quotes around these variables in the mentioned lines:

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 . 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 . 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.

/Library/Internet: binary operator expected

I had a similar error when trying to use Oracle JDeveloper on OS X.

I think the problem is the space in $JAVA_HOME environment variable. I simply made a symlink to the location of 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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