Java 在 NetBeans 项目中更改 JRE
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4128256/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change JRE in NetBeans project
提问by griegs
I have a NetBeans project which is using the JRE 1.4 environment which means I can't use generics.
我有一个使用 JRE 1.4 环境的 NetBeans 项目,这意味着我不能使用泛型。
How can I change the project to use 1.6 (?) so I can use generics.
如何将项目更改为使用 1.6 (?) 以便我可以使用泛型。
采纳答案by OliBlogger
- In the Project tab, Right Click on the Project and select
Properties
.In the Library category selectJava Platform JDK 1.6
. - Then, in the Source category select
Source/Binary
FormatJDK6
. - This assumes that you installed
JDK 1.6
andNetBeans
knows about this. JDK 1.6
must be known toNetBeans
as a Java Platform.- From the menu select Tools->Java Platform Manager.
- If
JDK 1.6
is not in the list you can add it there.
- 在 Project 选项卡中,右键单击 Project 并选择
Properties
。在 Library 类别中选择Java Platform JDK 1.6
。 - 然后,在 Source 类别中选择
Source/Binary
FormatJDK6
。 - 这假设您已安装
JDK 1.6
并NetBeans
了解这一点。 JDK 1.6
必须被称为NetBeans
Java 平台。- 从菜单中选择工具->Java 平台管理器。
- 如果
JDK 1.6
不在列表中,您可以在那里添加它。
回答by Mark Burleigh
There is a bug in NetBeans 8.0.2
NetBeans 8.0.2 中存在一个错误
When undertaking the above steps in changing JRE or JDK for a project, NetBeans attempts to save the project with the new JDK (9 in this instance) but it goes into an infinite loop and eventually gives an OutOfMemoryError:
在为项目更改 JRE 或 JDK 时执行上述步骤时,NetBeans 尝试使用新的 JDK(在本例中为 9)保存项目,但它进入无限循环并最终给出 OutOfMemoryError:
回答by Jovo Skorupan
In Netbeans 8.2,
在 Netbeans 8.2 中,
- right click the project, select Properties
- under the menu build/compile, select java platform from drop down menu
- 右键单击项目,选择属性
- 在菜单构建/编译下,从下拉菜单中选择 java 平台