Friday

Single Jar Scripts for Packaging JavaFX Application

Every JavaFX project in the NetBeans IDE has a file called build.xml in its main directory. Open this file and add the following text to the end, just before the < /project> closing tag:


< target name="package-for-store">
<echo message="packaging up ${ant.project.name}"/>

<!-- the name of your app, minus the .jar extension. should not have spaces.
or use the default (the name of your app)
<property name="jar.name" value="MyApp"/>
-->

<attribute name="Main-Class" value="${main.classname}"/>
</manifest>
</jar>
<zip destfile="final/${jar.name}.jar">
<zipfileset src="final/temp_final.jar" excludes="META-INF/*.SF, META-INF/*.DSA, META-INF/*.RSA"/>
</zip>

</target>

To use this, first edit the preceding jar.name and main.classname properties. Then do a clean and build from within NetBeans. From the command line, you can then run ant package-for-store. This will grab the final jar and its support libraries from the dist dir. It will recompress them into a single jar and strip any signatures.

This final jar will be in the final directory, and it will be named based on the properties listed earlier.

No comments: