can we resign the already signed jars in java?

Viewed 14003

I've a .jar file with an old signature and want to resign it with a new signature. Is it possible?

If it is possible: how to do it?

3 Answers

If the signature is not one you own, you would need to unjar the jar first.

Like so (assume unix, translate to dos otherwise):

jar xvf JarName.jar

rm -rf META-INF

jar cvf JarName.jar *

Now you need to run jarsigner to sign the jar

jarsigner -keystore /yourkeystoredirectory/mystore -storepass yourpass
      -keypass yourkeypasswd JarName.jar keyname

If you don't have a keystore, you can create one with keytool.

You can extract the class files and re-jar them with your signature

Related