If you use Netbeans for your Java development projects, you might wonder how to make the required external jar libraries embedded in your main jar file. Unfortunately, Netbeans doesn’t make it very intuitive. You have to add some lines to the build.xml file :

   <target name="int-jar">
       <jar jarfile="dist/finalApp.jar">
           <zipfileset src="${dist.jar}" excludes="META-INF/*" />
           <zipfileset src="lib/log4j-1.2.16.jar" excludes="META-INF/*" />
               <attribute name="Main-Class" value="com.example.package.Main"/>

The result will be an independent jar named finalApp.jar which includes, in this example, log4j library.

Les derniers articles par janua (tout voir)