Pigsaw Blog
All the pig that’s fit to saw

Sudden activity around Jars

I asked some smart colleagues today about a current Jar problem I was having, and got a great response.

The problem: You have an application which depends on other Jars. You want my application and its dependencies to be rolled up into one convenient Jar. You can insert a Class-Path attribute in the rolled-up Jar’s manifest file, but that will be relative to the Jar itself, and therefore any Jars you reference need to be outside your rolled-up Jar.

So the proposed solutions are: (1) Write your own Classloader. Or (2) Use the Fat Jar plugin for Eclipse, by Ferenc Hechler. Or (3) use One-JAR by Simon Tuffs.

All this is explained much more clearly by Simon Tuffs on his One-Jar page. He also suggests unzipping all your dependent Jars and rolling them up with your own code, which is something I considered, but also points out the potential problems.

And then, out of the blue, I read about JSR 277: Java Module System. A proposal by Sun to address exactly this issue. And possibly have something a bit like .NET’s assemblies.

Honestly, you wait for hours for a Jar-dependency solution, and then four come along at once.

Tags: , , ,

Leave a Reply »»