Well, the truth is, there is no one step way to do this. This is what users tend to do:

  • Extract the Jar file
  • Delete the Jar file
  • Run the Jar command to re-create the Jar file.

So yeah, I can make a batch file for this but since I have no idea how to make one, I decided to use Ant.

Here is my script.

The following explains the steps that the build script executes:

  • Go over all folders recursively to look for existing jar files.
  • Extracts them one by one in a folder name that is the name of the Jar file + “_folder”.
  • Delete the old Jar file
  • Re-create the Jar file
  • Delete the folder

That’s it! Simply put the build script file in any folder you want it to start searching for Jar files and it does the rest.

You most likely happened to re-sign an existing signed jar that just expired recently and got this error message saying invalid SHA1 signature.

There is only 1 cause for this and you happen to re-sign the jar using JDK 1.7 while the expired jar was signed using 1.6. The encryption for both JDKs are different because 1.6 uses SHA1 while 1.7 uses SHA-256.

When you re-sign the expired jar using 1.7, check the manifest file and you will see that there will be 2 entries labeled SHA1 and SHA-256.

The only workaround that can be done for this is to re-create a clean jar file and sign it using 1.7. However, in my case wherein there were too many jar files I decided to install 1.6 and use its jarsigner executable to re-sign it thereby keeping its signature intact as SHA1.

You can then verify your jar file with the command

jarsigner -verify -verbose -certs

just to be sure that the signing was successful. Do not worry if you see the message “This jar contains entries whose signer certificate has expired.” because this is normal as it simply means you overwrote an expired certificate with a new one.

I think it started with Java 1.6 that a JNLP jar file was included that can let you run a Java web start application or applet in a single instance.

Through the SingleInstanceService class, you application or applet will be able to detect if another instance is run when it is called from a JNLP.

I have not tried this with an applet that is run from an <APPLET> tag but I tested this in an applet if it is called from a JNLP.

Simply implement SingleInstanceListener from your class and initialize it with this code:

And in the newActivation() method, you can put in a message prompt that looks something like this:

Easy, right?

By the way, if this code is run within an IDE, it will return an exception. This will have to be run from a JNLP in order for it to work.

Related Posts Plugin for WordPress, Blogger...