Creating a JAR with dependencies

To package your application along with all dependencies in a single JAR file, you can use Ant's <zipfileset/> element to extract the referred libraries and package the included class files in your JAR.

<?xml version="1.0" encoding="utf-8"?>
<project>
    <target name="jar">
        <jar jarfile="dist/app.jar">
            <!-- Your project's classes -->
            <fileset dir="bin" includes="**/*.class"/>
            <!-- Dependency JARs -->
            <zipfileset src="lib/dependency.jar" includes="**/*.class"/>
        </jar>
    </target>
</project>