NetBeans 8.2 does not open on Mac OS

 ̄綄美尐妖づ 提交于 2021-02-05 20:31:18

问题


I am trying to start NetBeans 8.2 on a Macbook Pro and it's not working.

It shows the splash screen, then after a while it shuts down without starting anything.

Running from the command-line I can see this error:

Oct 02, 2017 7:40:28 PM org.netbeans.ProxyURLStreamHandlerFactory register
SEVERE: No way to find original stream handler for jar protocol
java.lang.reflect.InaccessibleObjectException: Unable to make field transient java.net.URLStreamHandler java.net.URL.handler accessible: module java.base does not "opens java.net" to unnamed module @7823a2f9
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:337)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:281)
    at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:175)
    at java.base/java.lang.reflect.Field.setAccessible(Field.java:169)
    at org.netbeans.ProxyURLStreamHandlerFactory.register(ProxyURLStreamHandlerFactory.java:82)
    at org.netbeans.JarClassLoader.<clinit>(JarClassLoader.java:141)
    at org.netbeans.MainImpl.execute(MainImpl.java:178)
    at org.netbeans.MainImpl.main(MainImpl.java:85)
    at org.netbeans.Main.main(Main.java:83)

Looks like Java 9 got bundled with it and it's causing an error. The documentation implies that NetBeans 8.2 uses JDK 8!?

How to use my own java to run NetBeans, or how to get NetBeans to start without this error?


回答1:


Yes, NetBeans 8.2 does use JDK 1.8, and specifically does not support JDK 1.9.

It's unclear from the OP which version of Java is desired to run with NetBeans, but the version of NetBeans to use is governed by the version of Java to be used:

[1] For Java 8, use Netbeans 8.2. Note that Java 9 is not supported. You can download NetBeans 8.2 bundled with JDK 8u141 for Mac OS here:

http://www.oracle.com/technetwork/articles/javase/jdk-netbeans-jsp-142931.html

Once it has been installed it no specific configuration for Java should be necessary.

[2] For Java 9 you must use a Development Build of NetBeans. That can be downloaded from http://bits.netbeans.org/download/trunk/nightly/latest/ but be sure that Mac OS X is selected from the Platform drop list before clicking Download.

For any version of NetBeans you can specify your own version of Java as follows:

  • Start NetBeans and select Java Platforms from the Tools menu.

  • Click the Add Platform... button.

  • Complete the wizard to locate the version of Java you want to use.

One final point: there is no problem having multiple versions of NetBeans installed and running concurrently using different JDKs, typically NetBeans 8.2 with JDK 1.8 and NetBeans Dev Build with JDK 1.9.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Update:

If NetBeans closes itself down on startup it may have an invalid JDK path. To change the JDK that NetBeans uses:

  • Locate the file netbeans.conf. It should be in the etc directory under the NetBeans installation directory.

  • Edit that file in a text editor. Locate the line containing the property netbeans_jdkhome. On my Windows 10 installation it looks like this:

    netbeans_jdkhome="C:\Java\jdk1.8.0_121"

  • Change the value for that property to specify the path to the desired JDK, save the file and restart NetBeans.




回答2:


As pointed in the comments:

I had tried to set netbeans_jdkhome in /Applications/NetBeans/NetBeans\ 8.2.app/Contents/Resources/NetBeans/etc/netbeans.conf to point to JDK 10, but still it did not work.

I had to install JDK 8, and set netbeans_jdkhome="/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home"

Uninstalling JDK 10 and using JDK 8 worked for me and setting netbeans_jdkhome="/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home" worked quite well.




回答3:


macOS 10.13.5 JavaJDK 10 installed as "System" JVM

I was able to install NetBeans, but unable to get it to function. Window would open, clicking on "New Project" or "New File" did absolutely nothing.

Was able to get it working (all modules and servers) by going into the configuration file at /Applications/NetBeans/NetBeans 8.2.app/Contents/Resources/NetBeans/etc/netbeans.conf

and editing the commented out path to JDK at the bottom of the file!

Cheers!




回答4:


Check Java JDK is installed on Mac, NetBeans 8.2 does use JDK 1.8(Java SE 8)

/usr/libexec/java_home -V

Matching Java Virtual Machines (2):
    12.0.1, x86_64: "Java SE 12.0.1"    /Library/Java/JavaVirtualMachines/jdk-12.0.1.jdk/Contents/Home
    1.8.0_211, x86_64:  "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home

if not , just install (no need remove exist JDK) https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html


modify /Applications/NetBeans/NetBeans 8.2.app/Contents/Resources/NetBeans/etc/netbeans.conf

netbeans_jdkhome="/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home"



回答5:


For NetBeans 8.2 JDK 1.8 should be used. If you installed JDK 1.9 or JDK 10.0 to your MacBook, you must uninstall that from your computer.



来源:https://stackoverflow.com/questions/46530960/netbeans-8-2-does-not-open-on-mac-os

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!