问题描述
我正在尝试在 Macbook Pro 上启动 NetBeans 8.2,但它不起作用.
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)
看起来 Java 9 与它捆绑在一起并导致错误.该文档暗示 NetBeans 8.2 使用 JDK 8!?
Looks like Java 9 got bundled with it and it's causing an error. The documentation implies that NetBeans 8.2 uses JDK 8!?
如何使用我自己的 java 来运行 NetBeans,或者如何让 NetBeans 启动而不出现此错误?
How to use my own java to run NetBeans, or how to get NetBeans to start without this error?
推荐答案
是的,NetBeans 8.2 确实使用 JDK 1.8,特别是不支持 JDK 1.9.
Yes, NetBeans 8.2 does use JDK 1.8, and specifically does not support JDK 1.9.
OP 不清楚希望哪个版本的 Java 与 NetBeans 一起运行,但要使用的 NetBeans 版本取决于要使用的 Java 版本:
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] 对于 Java 8,使用 Netbeans 8.2.请注意,不支持 Java 9.您可以在此处下载与 Mac OS JDK 8u141 捆绑在一起的 NetBeans 8.2:
[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
安装后,无需为 Java 进行特定配置.
Once it has been installed it no specific configuration for Java should be necessary.
[2] 对于 Java 9,您必须使用 NetBeans 的开发版本.可以从 http://bits.netbeans.org/download/trunk/nightly 下载/latest/,但请确保在点击下载之前从平台下拉列表中选择了Mac OS X.
[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.
对于任何版本的 NetBeans,您都可以指定您自己的 Java 版本,如下所示:
For any version of NetBeans you can specify your own version of Java as follows:
启动 NetBeans 并从工具菜单中选择Java平台.
点击添加平台...按钮.
完成向导以找到您要使用的 Java 版本.
Complete the wizard to locate the version of Java you want to use.
最后一点:安装多个版本的 NetBeans 并使用不同的 JDK 同时运行没有问题,通常是 NetBeans 8.2 with JDK 1.8 和 NetBeans Dev Build with JDK 1.9.
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.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
更新:
如果 NetBeans 在启动时自行关闭,则它的 JDK 路径可能无效.更改 NetBeans 使用的 JDK:
If NetBeans closes itself down on startup it may have an invalid JDK path. To change the JDK that NetBeans uses:
找到文件 netbeans.conf.它应该在 NetBeans 安装目录下的 etc 目录中.
Locate the file netbeans.conf. It should be in the etc directory under the NetBeans installation directory.
在文本编辑器中编辑该文件.找到包含属性 netbeans_jdkhome 的行.在我的 Windows 10 安装中,它看起来像这样:
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"
更改该属性的值以指定所需 JDK 的路径,保存文件并重新启动 NetBeans.
Change the value for that property to specify the path to the desired JDK, save the file and restart NetBeans.
这篇关于NetBeans 8.2 无法在 Mac OS 上打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!