Saturday, February 12, 2011

Sign Your Applet (JAR Signing)

you create an Applet and when you run it using a browser some times you get following Errors.
access denied (java.io.FilePermisson C:\text.txt read write)
or
SocketPermission connect.

but if you run the same code in command line or in Swing GUI then works fine.

So what is the problem ?


Problem is when you run an Applet some restrictions are applied.such as accessing to a file systems, connecting via Sockets and many more.

So how do I run My applet with all functionality ?
Solution is Sign your Applet Jar .

1 . Open Command Prompt
2. Set the path to JDK\bin . in my system it's C:\Program Files\Java\jdk1.6.0_23\bin
3 type keytool -list to see already created keys by you
4. if you have already created a key pair the you can skip to Now Sign your Applet(Jar)
5. type keytool -genkey press enter and .
6 if required for password enter a password .
7. confirm the password
8. Enter the your First Name
9. Enter the name of your organizational unit.
10.Enter the name of your organization
11. Enter Your City
12. Enter Your State
13. Enter Your two-letter country code
14. Enter yes
15. press Enter Key if you wish to use same password as above. if not enter a new password and confirm it.
Now Sign your Applet(Jar)
Just Type jarsigner C:\jartosign\myapp.jar mykey
Enter passwords if required.

* C:\jartosign\myapp.jar - This should point your jar file.

No comments:

Just Answer


JustAnswer.com