Self signing jar file, doesn't find JarSigner class

5.5k views Asked by At

I'm trying to sign my java applet. I ran the following lines to create a cert:

keytool -genkey -keystore myKeyStore -alias ben
keytool -selfcert -keystore myKeyStore -alias ben

up to here everything works well. It requires a password and some details and creates the MyKeyStore file.

Then I run this line:

jarsigner -keystore myKeyStore nnis.jar ben

But all it does is tell me:

Error: Could not find or load main class sun.security.tools.JarSigner

the file tools.jar (in which the JarSigner.class exists) is in the "PATH", and just to be sure, I also copied it to the local dir from which I run the jarsigner command.

What am I doing wrong?

I would appreciate any advice - to solve the problem or bypassing it.

1

There are 1 answers

0
Peter D On

Jarsigner.exe searches for tools.jar relative to its own location. In the JDK, they are located in:

<jdk-install-folder>\bin\jarsigner.exe
<jdk-install-folder>\lib\tools.jar

As long as you maintain the same relative folder structure, it should find the JarSigner class. For example if your jarsigner.exe is in C:\Temp\YourFolder\jarsigner.exe, you should put the tools.jar in C:\Temp\lib\tools.jar.