Wednesday, May 10, 2006

Create Digitally Signed for JAVA

1. Using keytool to create a key and assign it an alias and password:

keytool -genkey -alias wangzjkey -keypass wangzjpw
the -genkey argument generates a new key, which is 'wangzjkey' and password 'wangzjpw'.

if this is the first time keytool has been used, you'll be promopted for a password that protects access to the key database, which is called a keystore.

2. After a key is placed in the keystore, it can be used with the jarsigner tool to sign an archive file. This tool requires the keystore and key passwords and alias of the key. for example

jarsigner -storepass wangzjpw -keypass wangzjpw xxx.jar wangzjkey

the keystore password in this example is wangzjpw.