ant hello world
建一上文件夹HelloWorld.里面的内容如下所示:
第一个例子不讨论build1.xml和HelloWorld1.java.运行出helloworld程序要如下步骤:
1.建一个文件夹,用于保存编译成的.class
2.编译.java文件,生成.class文件
3.运行程序,出结果
第1步通过下面代码实现
第2步通过下面代码实现
compilation complete!
第3步通过下面代码实现.
classname="edu.cgxy.helloworld.HelloWorld"
classpath="out/classes">
build.xml的完整例子如下:
Compiles and runs a simple program
compilation complete!
classname="edu.cgxy.helloworld.HelloWorld"
classpath="out/classes">
执行命令ant -f build1.xml可以运行结果. 还有一个名字为clean的target上面没有介绍.作用是运行程序之后先把以前的结果删除.
程序源代码: https://github.com/zhouyang209117/AntTutorial/tree/master/HelloWorld