項目結構:
test1
src
test1
WEB-INF
classes
build.xml
1.build.xml
<?xml version="1.0"?>
<project name="project" default="run" basedir=".">
<target name="compile">
<javac destdir="WEB-INF/classes" srcdir="src"></javac>
</target>
<target name="run" depends="compile">
<java classname="test1.Hello" classpath="WEB-INF/classes"></java>
</target>
</project>
2.Hello.java
package test1;
public class Hello{
public static void main(String[] arg){
System.out.println("hello world!!!!!!");
}
}
命令行中輸入ant運行