HelloWorld.java
package com.chan.test;
public class HelloWorld{
public static void main(String args[]){
System.out.println("Hello Chan include package");
}
}
build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="antTest" default="compile" basedir=".">
<!--编译程序-->
<target name="clean">
<delete dir="bin"/>
</target>
<target name="compile" depends="clean">
<mkdir dir="bin/classes"/>
<javac srcdir="." destdir="bin/classes"/>
</target>
<target name="run" depends="compile">
<!-- 运行java-->
<java classname="com.chan.test.HelloWorld">
<!-- class的路径-->
<classpath>
<pathelement path="bin/classes"/>
</classpath>
</java>
</target>
</project>
命令行运行
ant run