Tag Archives: application

Playing with Jars

Recently, I came across a problem when updating a jar file.
How does one update a jar file with a class file using a particular packaging?

So you have a jar file named foo.jar with two elements in it, a package (fooPackage) containing multiple class files and your manifest.
You also have a class named bar.class that is packaged by fooPackage (*see bottom).
Do you think this will package it correctly?

>> jar uf foo.jar bar.class

No. Not really. It adds bar.class to foo.jar without a hitch, but does not keep your packaging path. Instead, it adds bar.class to foo.jar, but outside the package path you want.
If this was a stand-alone java application, this will not reflect your changes when running.

With this being said, I turned to a few external solutions to solve this problem.
After hours of frustration with a few programs (ie: DJ Java Decompiler), I finally ended up using WinRAR that did the trick and placed the bar.class in the correct package path (graphically).

*Note: When I say packaged by fooPackage I mean that the .java equivalent of bar.class has the code: package fooPackage;