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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 11:54:18  来源:igfitidea点击:

Change JRE in NetBeans project

javanetbeansnetbeans-6.9

提问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 select Java Platform JDK 1.6.
  • Then, in the Source category select Source/BinaryFormat JDK6.
  • This assumes that you installed JDK 1.6and NetBeansknows about this.
  • JDK 1.6must be known to NetBeansas a Java Platform.
  • From the menu select Tools->Java Platform Manager.
  • If JDK 1.6is not in the list you can add it there.
  • 在 Project 选项卡中,右键单击 Project 并选择Properties。在 Library 类别中选择Java Platform JDK 1.6
  • 然后,在 Source 类别中选择Source/BinaryFormat JDK6
  • 这假设您已安装JDK 1.6NetBeans了解这一点。
  • JDK 1.6必须被称为NetBeansJava 平台。
  • 从菜单中选择工具->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:

infinite loop while saving new project with new JDK

使用新 JDK 保存新项目时出现无限循环

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 平台