Studyon Minte9.com
Netbeans




App embeded jar



Use Netbeans and Ant to combine all .jar files (including external libraries) in one .jar file.

1) Edit build.xml (change the line <property name="store.jar.name" value="testexample"/>)

<?xml version="1.0" encoding="UTF-8"?> <project name="testexample" default="default" basedir="."> <description>Builds, tests, and runs the project testexample.</description> <import file="nbproject/build-impl.xml"/> <target name="package-for-store" depends="jar"> <property name="store.jar.name" value="testexample"/> // --- Look Here --- // <!-- don't edit below this line --> <property name="store.dir" value="store"/> <property name="store.jar" value="${store.dir}/${store.jar.name}.jar"/> <echo message="Packaging ${application.title} into a single JAR at ${store.jar}"/> <delete dir="${store.dir}"/> <mkdir dir="${store.dir}"/> <jar destfile="${store.dir}/temp_final.jar" filesetmanifest="skip"> <zipgroupfileset dir="dist" includes="*.jar"/> <zipgroupfileset dir="dist/lib" includes="*.jar"/> <manifest> <attribute name="Main-Class" value="${main.class}"/> </manifest> </jar> <zip destfile="${store.jar}"> <zipfileset src="${store.dir}/temp_final.jar" excludes="META-INF/*.SF, META-INF/*.DSA, META-INF/*.RSA"/> </zip> <delete file="${store.dir}/temp_final.jar"/> </target> </project>
  2) Netbeans (switch to Files mode) and right click:
build.xml (right click) Run Target Other Targets -> package-for-store
Ant target will create a directory called store/ inside your project directory. Then will copy all of the classes and libraries into a temporary JAR file and strip out any unwanted files.


http://www.oracle.com/technetwork/articles/javase/index-139904.html
http://stackoverflow.com/questions/10505057/netbeans-export-to-jar-include-all-library-files
http://stackoverflow.com/questions/10834589/netbeans-how-can-i-include-external-jar-fileslib