Pages

Friday, November 22, 2013

How to Sign Jar Files for Web Deployment of Java Applets, an Easy Java Simulation applet example.

How to Sign Jar Files for Web Deployment of Java Applets, an Easy Java Simulation applet example.
this tutorial serves to allow you to sign your own EJS applets.


  1. install latest JDK from http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html. For example, Windows x86 for Windows  XP operating system
  2. after installation, there should be C:\Program Files\Java\jdk1.7.0_45\bin where the keytool.exe is located. 
  3. in order to run the cmd line keytool, add the PATH to include C:\Program Files\Java\jdk1.7.0_45\bin by going to Start , Settings, Control Panel 
  4. Navigate to System, Environment Variables, Path Edit and add ;C:\Program Files\Java\jdk1.7.0_45\bin to the Variable value, so that the cmd line keytool avoid the error 'keytool' is not recognized as an internal or external command, operable program or batch file.
  5. Now, you are ready to go and type some lines by Naviagting to Start, Run 
  6. type in cmd and press enter in the keyboard 
    cmd
  7. this will bring up a C:\WINDOWS\system32\cmd.exe console
  8. in order to save yourself some heavy typing, use the windows explorer to navigate to the folder where you saved all your jar files that you want signed. For example copy F:\Dropbox\Public\lookangEJSworkspace\export
  9.  go to  C:\WINDOWS\system32\cmd.exe console and do a right click and paste after you type cd  F:\Dropbox\Public\lookangEJSworkspace\export 
  10. to get cd  F:\Dropbox\Public\lookangEJSworkspace\export and you need to type f: if you are using a different drive like me 
    cd F:\Dropbox\Public\lookangEJSworkspace\export
    f:
  11. type keytool -genkey -keystore myKeystore -alias myAlias -validity 1800 , for my example my Alias is lookang, i recommend to keep myKeystore as it is and adding -validity 1800 for a 1800 days of certification instead of the default 6 months. i used keytool -genkey -keystore myKeystore -alias lookang -validity 1800 
    keytool -genkey -keystore myKeystore -alias lookang -validity 1800
  12. enter your own password, don't tell anyone this password and follow the instruction the best you see fit  
  13. notice that a new file called myKeystore is generated in the folder F:\Dropbox\Public\lookangEJSworkspace\export 
  14. u are now ready to sign all jar applets using that just created myKeystore. type or copy this jarsigner -keystore myKeystore myJar.jar myAlias but for my case i will type jarsigner -keystore myKeystore ejs_model_RocketTemplatewee.jar lookang . you need to replace myJar.jar with the name of the own *.jar files and the myAlias also need to replace to the myAlias you used, for my case lookang. When ask for the Passphrase, just key in your password you used in step 12.
    jarsigner -keystore myKeystore ejs_model_RocketTemplatewee.jar lookang
  15. now, how do i create a *.bat to run all this command for my 100+ applets? leave a Google+ comment at the bottom of this post and tell how :) Enjoy!

Reference:

No comments:

Post a Comment