How to sign a JAR file

Talking about certificates is beyond the scope of this page. Here we present a brief example using the tools keytool and jarsigner included in the Java SDK.

More and better information about these tools can be:

Assuming both tools are in the PATH environment variable, the basic steps are:

  • Create a certificate, it can be done only once.
  • Export the certificate to a file.
  • Sign your files with the certificate.
> keytool -genkey -keyalg rsa -alias somename
 Enter pw : ******

> keytool -export -alias somename -file somename.crt

> jarsigner file.jar yourname