Creating JAR files with dependencies

Phill's J2EE Blog

File this one under “spend a few minutes Googling without success!”

If you’re trying to package up a Java application into one JAR file for easy deployment – including all dependency JAR files – there aren’t many options.

There’s a plugin for Eclipse called “Fat Jar” which I haven’t tried out. I’ve just discovered a tool called One-Jar, which does the trick. It’s simple to use. In my case, using Ant, it was a matter of:

  • Download the One-Jar JAR file.
  • Run it (using java -jar) to extract the contents
  • Add the one jar ant task plugin .jar file to my ant lib folder
  • Import the one-jar-ant-task.xml build file into my build file
  • Create a manifest.mf file with the One-Jar-Main-Class set
  • Add in the <one-jar> task to my existing build.xml file as per the instructions.
  • And you’re done!

The ant task does a lot of the work…

View original post 24 more words

Advertisements

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