Save the following as Build.xml:
<?xml version= "1.0" encoding= "UTF-8"?>
<project name="Project name" basedir="." default="Jar">
< Property &NBSP; name= " Src.dir " &NBSP;&NBSP;&NBSP;&NBSP;&NBSP; Span style= "font-size:13px;color:navy;font-family: ' Courier New '" >value= " src " />
< Property &NBSP; name= " Jar.dir " &NBSP;&NBSP;&NBSP;&NBSP;&NBSP; Span style= "font-size:13px;color:navy;font-family: ' Courier New '" >value= " out " />
< Property &NBSP; name= " Bin.dir " &NBSP;&NBSP;&NBSP;&NBSP;&NBSP; Span style= "font-size:13px;color:navy;font-family: ' Courier New '" >value= " bin " />
< Property &NBSP; name= " Lib.dir " &NBSP;&NBSP;&NBSP;&NBSP;&NBSP; Span style= "font-size:13px;color:navy;font-family: ' Courier New '" >value= " Lib " />
<path id="classpath">
<fileset dir= " ${lib.dir} " &NBSP; includes= "**/*.jar" />
</path>
<target &NBSP; name= " compile " >
<mkdir dir="${bin.dir}"/>
<javac srcdir="${src.dir}" destdir="${bin.dir}" classpathref="Classpath"/>
</target>
<target &NBSP; name= " clean "
<delete &NBSP; file= " ${jar.dir}/${ Ant.project.name}.jar " />
<delete &NBSP; dir= " ${bin.dir} " />
</target>
<target &NBSP; name= " jar " depends= " clean,compile " >
<mkdir &NBSP; dir= " ${jar.dir} " />
<jar &NBSP; destfile= " ${jar.dir}/${ Ant.project.name}.jar " basedir= " ${bin.dir} " />
</target>
</project>
You only need to replace the project name, such as memcached, and the resulting jar is Memcached.jar.
The basic process of the jar target:
1) clean , clear the original bin and Span style= "font-family: ' Times New Roman '" >out directory, i.e. delete .class and .jar file
2) compile , using classpath Reference compile-time required jar , All files under src are compiled, generated by .class placed in bin in the directory.
3) Build the jar, Create a new out directory, and package all the files under the bin into the " project name . Jar"and place it in the Out directory.
Basic syntax for generating jar packages for common Java projects (using ant packaging)