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

查看:87
本文介绍了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

构建 - >编译

在较低的一侧你会看到其他编译器选项

on lower side you will see Additional Compiler options

将参数设为 -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天全站免登陆