Issue
I am using netbeans and have this in my build.xml file (under Project > Build.xml)
<target name="package-for-store" depends="jar">
<property name="store.jar.name" value="MyProjectName"/>
<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"/>
Supposedly what this should do is package the 3 libraries i have into my jar file so that when the jar is run it has its dependencies with it.
My folder system looks like this:
Project / dist / lib /
- commons-lang3-3-7.jar
- commons-text-1.1.jar
- jsoup-1.10.3.jar
But when i click "Clean and Build" in netbeans it does not package the libraries into the jar, instead it seems to be ignoring the code that i have put in the build.xml file.
Is there some button that i need to click in order to get it to use my build configuration?
Solution
Finally i found the answer. In Netbeans it is possible to build the dependent libraries within the jar file.
Netbeans features a tool that automatically un-archives the dependent libraries and includes them in the jar (such as MyJar.jar|org\apache\commons...).
And it is actually very easy to do!
First you need to click on the "Files" tab in the top left window which shows your project. Then you should be able to see all your files including the Build.xml (in which you have put your build code, such as that featured in the question above).
Right click on the Build.xml file and select "Run Target"
Then choose "Other Target" in the pop up menu
Then select "package-for-store" in the further pop up menu
This will then build your jar file, with dependencies under /YourProject/store/
Answered By - JFreeman