netbeans jarsigner woes

Ok so this is about the dreaded jarsigner error :

unable to sign jar: java.util.zip.ZipException: invalid entry compressed size

99% of the time what that means is your jar is already signed

However jarsigner has no way to remove signatures from a jar , but you can do that manually since a jar file is a zip archive all you have to do is extract it , delete the META-INF directory and repack it.

Personally i use muCommander , you have to do this : shift+F6 (rename to .zip) > enter > del META-INF > enter > shift+F6 (rename back)
It treats archives as standard directories so it automatically handles the unpacking and repacking of the archive transparently

If you are a terminal lover you can run this for the same results:

zip -d YourJar.ext “META-INF*”

deleting: META-INF/MANIFEST.MF
deleting: META-INF/CERT.SF
deleting: META-INF/CERT.RSA

Which is going to result in this :
deleting: META-INF/MANIFEST.MF
deleting: META-INF/CERT.SF
deleting: META-INF/CERT.RSA

The reason why i have to go into all this is because unlike Eclipse , Netbeans has no way of building a unsigned android apk (unless you mess about with -sign in nbproject/build-impl.xml) but this should apply and work with any kind of java package signing scenario (except the Maven jarsigner which blissfully has a unsign feature)
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