) 設置ANT_HOME環境變量指向你的ANT目錄
) 需要設置JAVA_HOME環境變量指向你的JDK目錄
) 將%ANT_HOME%\bin加入到PATH環境變量中
) 當你不帶任何參數運行ant時Ant會在當前目錄找一個名叫buildxml的文件如果沒找到會有以下提示
Buildfile : buildxml does not exist!Build failed
為了測試ANT安裝是否成功我建立了一個新的buildxml文件放在當前的目錄下%ANT_HOME%\samplesBuildxml內容如下
<! Simple Ant build script to test an Ant installation ><br />
<project name=TestInstall default=run basedir=><br />
<target name=init> <br />
<available file=ASimpleHelloObjectjava property=ASimpleHelloObject/> <br />
</target> <br />
<target name=ASimpleHelloObject unless=ASimpleHelloObject depends=init> <br />
<echo file=ASimpleHelloObjectjava><br />
public class ASimpleHelloObject<br />
{<br />
public static void main(String[] args) { <br />
Systemoutprintln(ASimpleHelloObjectmain was called); }<br />
}<br />
</echo> <br />
<echo message=Wrote ASimpleHelloObjectjava /> <br />
</target> <br />
<target name=compile depends=ASimpleHelloObject> <br />
<javac destdir= srcdir= debug=on classpath=> <br />
<include name=ASimpleHelloObjectjava/> <br />
</javac> <br />
</target> <br />
<target name=run depends=compile> <br />
<java classname=ASimpleHelloObject classpath= /> <br />
<echo message=Ant appears to be successfully installed /> <br />
</target><br />
</project><br />
[] [] [] [] [] [] [] []
From:http://tw.wingwit.com/Article/program/Java/ky/201311/29227.html