Ant set platforms.JDK_1.6.home不带参数

我有一个问题,试图在Windows机器上运行ant。 我得到以下错误:

BUILD FAILED C:\Users\USER\testing\mercurial\project\NetbeansProject\nbproject\build-impl.xml:111: The J2SE Platform is not correctly set up. Your active platform is: JDK_1.6, but the corresponding property "platforms.JDK_1.6.home" is not found in the project's properties files. Either open the project in the IDE and setup the Platform with the same name or add it manually. For example like this: ant -Duser.properties.file=<path_to_property_file> jar (where you put the property "platforms.JDK_1.6.home" in a .properties file) or ant -Dplatforms.JDK_1.6.home=<path_to_JDK_home> jar (where no properties file is used) 

如果我执行ant -Dplatforms.JDK_1.6.home=%JAVA_HOME%它执行得很好,但是,有没有办法避免每次我需要build立一个程序时添加这个参数呢?

我不认为可以在命令行之外设置ant属性,或者通过构建脚本显式地加载属性文件。

如果您正在寻找一种不太复杂的方式来启动ant ,请尝试使用包装器.bat文件或分配别名doskey ant=ant "-Dplatforms.JDK_1.6.home=%JAVA_HOME%"