[转]Eclipse下Ant的使用

目前的Eclipse都集成了ant,本文图示如何在eclipse下使用ant
1.新建Java Project-新建Java文件HelloWorld.java
HelloWorld.java
package example;
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
2.在工程根目录下新建build.xml
build.xml
<?xml version="1.0" encoding="utf-8"?>
<project default="main" basedir=".">
<target name="main" depends="compile, compress" description="Main target">
<echo>Building the .jar file.</echo>
</target>
<target name="compile" description="Compilation target">
<javac srcdir="${basedir}/src/example" />
</target>
<target name="compress" description="Compression target">
<jar jarfile="HelloWorld.jar" basedir="${basedir}/src/example" includes="*.class" />
</target>
</project>
此脚本文件内容是编译/src/example下的java文件,并就地生成class文件,将这个class文件打成jar包,HelloWorld.jar
更多信息请访问:“子 孑” 博客,http://zhangjunhd.blog.51cto.com/113473/128317
yava /
in categories tagged with