Netbeans - 构建面向 JDK 6 但使用 Java 7 JRE 运行 [英] Netbeans - Build targetting JDK 6 but run using Java 7 JRE

查看:19
本文介绍了Netbeans - 构建面向 JDK 6 但使用 Java 7 JRE 运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个需要针对 JDK 1.6 进行构建的项目,但我想针对 Java 1.6 和 1.7 对其进行测试 - 我同时安装了 Java 1.6 和 1.7 JDK.

I'm working on a project where I need to build against JDK 1.6 but I would like to test it against both Java 1.6 and 1.7 - I have both Java 1.6 and 1.7 JDKs installed.

我知道我可以为每个平台创建一个新的 Java 平台,但这会导致项目也针对 JDK 1.6/1.7 构建 - 我只希望它针对这两个平台运行.是否有一种简单的方法可以告诉 Netbeans 针对我的 JDK 1.6 平台构建但使用我的 Java 1.7 JRE 运行.或者,即使可以选择使用外部 JRE 来运行项目,我也可以让它工作.

I know I can create a new Java Platform for each but that would result in the project being built against JDK 1.6/1.7 as well - I only want it run against both. Is there an easy way to tell Netbeans to build against my JDK 1.6 Platform but run using my Java 1.7 JRE. Or even if there is an option for using an external JRE to run the project with I could make it work.

推荐答案

通过右键单击左侧窗格转到项目属性

Go to the project properties by right clicking on the left hand pane

构建->编译

在下方,您会看到其他编译器选项

将参数指定为 -target 6 这将根据 JDK 6 编译您的代码,当您运行该程序时,它将使用 JRE 运行它7.

give the params as -target 6 and this will compile you code according to JDK 6 and when you will run the program it will run it using JRE 7.

这篇关于Netbeans - 构建面向 JDK 6 但使用 Java 7 JRE 运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆