1. Extract the other jar packages into your classes directory and then play them together as executable jar packages.
Build.xml as follows:
<?xml version= "1.0"?>
<project name= "parser" default= "compile" basedir= "." >
<target name= "Init" >
<mkdir dir= "Bin" > </mkdir>
<mkdir dir= "Dest" > </mkdir>
</target>
<path id= "Classpath.local" >
<pathelement location= "./lib/log4j-1.2.14.jar"/>
<pathelement location= "./lib/mysql-connector-java-5.0.7-bin.jar"/>
<pathelement location= "./lib/je-3.2.43.jar"/>
<pathelement location= "./lib/nekohtml.jar"/>
<pathelement location= "./lib/tidy.jar"/>
<pathelement location= "./lib/xercesimpl.jar"/>
<pathelement location= "Bin"/>
<pathelement location= "bin/com"/>
<pathelement location= "." />
</path>
<target name= "Compile" depends= "init" >
<javac destdir= "bin" srcdir= "src" >
<classpath refid= "Classpath.local"/>
</javac>
</target>
<target name= "Run" depends= "compile" >
<java classname= "Bin/parser" classpath= "classpath.local" > </java>
</target>
<target name= "dest" depends= "compile" >
<mkdir dir= "Dest" ></mkdir>
<jar jarfile= "Dest/parser.jar" basedir= "Bin" ></jar>
</target>
<target name= "clean" >
<delete dir= "Bin" > </delete>
<delete dir= "Dest" > </delete>
</target>
<target name= "Unziplib" >
<unjar dest= "Bin" >
<fileset dir= "Lib" includes= "*.jar"/>
</unjar>
</target>
<target name= "jar" depends= "Compile,unziplib" >
<jar jarfile= "Dest/parser.jar" basedir= "Bin" >
<manifest>
<attribute name= "Main-class" value= "Com.dyoldfish.parser.Parser"/>
</manifest>
</jar>
<copy todir= "Dest" >
<fileset dir= "Doc" >
<include name= "Parser.bat"/>
<include name= "Clean.bat"/>
</fileset>
</copy>
</target>
</project>
2. Put the other Jar package library outside your executable jar package and pack
Build.xml as follows:
<?xml version= "1.0"?>
<project name= "parser" default= "compile" basedir= "." >
<target name= "Init" >
<mkdir dir= "Bin" > </mkdir>
<mkdir dir= "Dest" > </mkdir>
</target>
<path id= "Classpath.local" >
<pathelement location= "./lib/log4j-1.2.14.jar"/>
<pathelement location= "./lib/mysql-connector-java-5.0.7-bin.jar"/>
<pathelement location= "./lib/je-3.2.43.jar"/>
<pathelement location= "./lib/nekohtml.jar"/>
<pathelement location= "./lib/tidy.jar"/>
<pathelement location= "./lib/xercesimpl.jar"/>
<pathelement location= "Bin"/>
<pathelement location= "bin/com"/>
<pathelement location= "." />
</path>
<target name= "Compile" depends= "init" >
<javac destdir= "bin" srcdir= "src" >
<classpath refid= "Classpath.local"/>
<!--include name= "com/**"/-->
</javac>
<copy todir= "Bin" >
<fileset dir= "Doc" includes= "Run.bat"/>
</copy>
</target>
<target name= "Run" depends= "compile" >
<java classname= "Bin/parser" classpath= "classpath.local" > </java>
</target>
<target name= "dest" depends= "compile" >
<mkdir dir= "Dest" ></mkdir>
<jar jarfile= "Dest/parser.jar" basedir= "Bin" ></jar>
<!--copy todir= "Dest"/-->
<!--fileset dir= "bin" includes= "*.class"/-->
<!--/copy-->
</target>
<target name= "clean" >
<delete dir= "Bin" > </delete>
<delete dir= "Dest" > </delete>
</target>
<target name= "Jar" depends= "compile" >
<jar jarfile= "Dest/parser.jar" basedir= "Bin"
includes= "Com/**/*.class" >
<manifest>
<attribute name= "Main-class" value= "Com.dyoldfish.parser.Parser"/>
<attribute name= "Class-path" value= ". .. /lib/log4j-1.2.14.jar. /lib/mysql-connector-java-5.0.7-bin.jar. /lib/je-3.2.43.jar. /lib/nekohtml.jar. /lib/tidy.jar. /lib/xercesimpl.jar "/>
</manifest>
<!--fileset dir= "Lib" includes= "*.jar"/-->
</jar>
<copy todir= "Dest" >
<fileset dir= "Doc" includes= "Parser.bat"/>
</copy>
</target>
</project>
How to make a hit executable jar package can contain an extract file from an external library