简体   繁体   English

Netbeans - 构建目标JDK 6但使用Java 7 JRE运行

[英]Netbeans - Build targetting JDK 6 but run using Java 7 JRE

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. 我正在开发一个需要针对JDK 1.6进行构建的项目,但我想针对Java 1.6和1.7进行测试 - 我安装了Java 1.6和1.7 JDK。

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. 我知道我可以为每个人创建一个新的Java平台,但这也会导致项目针对JDK 1.6 / 1.7进行构建 - 我只希望它针对两者运行。 Is there an easy way to tell Netbeans to build against my JDK 1.6 Platform but run using my Java 1.7 JRE. 是否有一种简单的方法可以告诉Netbeans使用我的JDK 1.6平台构建,但使用我的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. 或者即使有一个使用外部JRE来运行项目的选项,我也可以使它工作。

Go to the project properties by right clicking on the left hand pane 右键单击左侧窗格转到项目属性

Build->Compiling 建设- >编译

on lower side you will see Additional Compiler options 在较低的一侧,您将看到Additional Compiler选项

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 . 将params命名为-target 6 ,这将根据JDK 6编译代码,当您运行程序时,它将使用JRE 7运行它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM