Signing Applets
Yeah, there a lot of tutorials out there about signing Applets, but since anything you make with Switchboard will need to be signed to run online, I thought I'd provide another one here, specifically for Processing projects that use Switchboard. Basically, we will be using two applications that ship with any JRE, keytool and jarsigner.
- In your Processing project, go to
File > Exportor hitCtrl+E. A window will open with a bunch of files. - Open a console and go to the directory that just opened. (tip: on Windows, you can do this by typing
cdand then dragging the folder icon in the address bar of your Explorer window onto the console) - The first thing we will be doing is creating a key. If you have already done this step before, skip to step 6. A key is basically like a little file that says who you are. To make it, type the following line into the console.
keytool -genkey -alias [your alias]
- Hit enter and you will be prompted for your keystore password. Your keystore is just a collection of keys, and since we didn't specify a specific keystore, the keytool will use the default keystore on the machine. Remember this password, because when you want to sign another applet with the key, you will need it.
- Next it is going to ask you a bunch of questions. Answer the ones you want. This is the information that is going to appear in the little dialog box when the user of your applet tries to run it in. When it asks you for a password, leave it blank and use the default option:
use keystore password. This way you only have to remember one password. - The next step is to use the key that you just created to sign the applet.
jarsigner YourJarFile.jar [your alias]
- Now you're all set.
Troubleshooting
keytool error: java.lang.Exception: Key pair not generated, alias <blahblah> already existsYou've already created a key, so you can move on to signing the jar. Sip to step 6.
jarsigner: attempt to rename blah.jar to blah.jar.orig failedThis usually happens if you have your applet open when you are trying to sign it. What the keytool does is create another version of the applet that is signed, and then tries to replace the original with the signed one. But if some application has a lock on the applet, then it won't be able to replace it. Close anything that might be accessing the applet and try again.
