How to include the processing jars (and others) in your Netbeans JAR

How to include the processing core inside your JAR.

By default , upon project build, Netbeans copies all referenced libraries to a /lib/ folder inside the /dist/ folder. That is a bit of a pain, because we now have to distribute a whole lot of .jar files, which is a bit “messy” ..

If you want or need to generate a single executable JAR file that will contain all referenced libraries, here is how to do it : All you need to do is add the following line to your build.xml file:

<target name=”-pre-jar”>
<unjar src=”${file.reference.core.jar}” dest=”${build.classes.dir}”/>
</target>

The code above code unjars the core.jar to the build directory before netbeans builds your project.

The ${file.reference.core.jar} is a pointer to the core.jar that the project uses. You can find the pointer for the core.jar file (and all other processing and non-processing libraries you may be using) in the private.properties file (which can found in the nbproject/private folder).

This private.properties file contains a line like the following :

file.reference.core.jar=/Applications/Processing XXXX/lib/core.jar

So, now you can generate a single .jar file for each of your netbeans projects.

In our next article, we will see how to “embed” various types of files in a .jar file to emulate the processing jar-embedding of everything contained in the ../SketchPath/data/ folder.

Advertisements

6 thoughts on “How to include the processing jars (and others) in your Netbeans JAR

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s