2013-04-12 80 views
2

我在嘗試在Windows機器上運行ant時出現問題。我得到以下錯誤:Ant set platforms.JDK_1.6.home無參數

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%它執行罰款,但是,有一些方法,以避免每次我需要建立一個程序時加上這個參數?

+0

一個更簡潔的方式讓你嘗試添加'<屬性名=「platforms.JDK_1.6.home 「value =」$ {env.JAVA_HOME}「/>'在調用之前? – Alex

+0

@Alex我應該在哪裏添加該屬性?我只需要在一臺計算機上解決此問題,因此我無法修改構建文件。 有什麼方法可以定義這個屬性系統範圍? –

回答

2

我不認爲有可能在命令行外設置ant屬性,或者由構建腳本顯式加載屬性文件。

如果您正在尋找推出ant,嘗試使用一個包裝.bat文件,或指定一個別名doskey ant=ant "-Dplatforms.JDK_1.6.home=%JAVA_HOME%"