How to sign a Java applet for use in a browser

Step 1 - Generate the RSA key:

keytool -genkey -keyalg rsa -alias mykey -validity 3650

Step 2 - Create the jar file:

jar -cf myapplet.jar applet.class

Step 3 - Sign the jar file:

jarsigner myapplet.jar mykey

Step 4 - Verify the jar file:

jarsigner -verify -verbose -certs myapplet.jar

Add the following code in your webpage to display the applet:

<APPLET CODE="myapplet.class" archive="myapplet.jar" WIDTH=500 HEIGHT=100>

</APPLET>