1、编写Hello.java
java 代码
- package ant;
- public class HelloAnt
- {
- public static void main(String[] args)
- {
- System.out.println("Hello Ant....!");
- }
- }
2、编写ant文件
xml 代码
- <?xml version="1.0" encoding="GB2312" standalone="no"?>
- <project default="run" basedir=".">
- <!--编译-->
- <target name="build">
- <mkdir dir="build\classes" />
- <javac srcdir="src\ant" destdir="build\classes" />
- </target>
- <!--运行-->
- <target name="run" depends="build">
- <java classname="ant.HelloAnt">
- <classpath>
- <pathelement path="build\classes" />
- </classpath>
- </java>
- </target>
- </project>
3、运行,成功。