APPLET tag is not working with self-signed applet jar

I've self-signed applet jar. I've created the policy file also (granting all permission). This applet is basically uploading multiple files using HttpClient to post request. I'm able to run via appletviewer command like: appletviewer -J-Djava.security.policy=mypolicy signedapplet.html . It works fine. But when i embed it into my html file and try to open the html by clicking on it, the applet got successfully loaded but when i browse a file then it throws an exception. Exception on java console..java.security.AccessControlException: access denied (java.io.FilePermission C:\Documents and Settings\Navneet\My Documents\Jassi.doc read)

I don't know where i went wrong. If it works on appletviewer, why not on html.Do i need to do something extra to work it.

Any suggestion/solutions are most welcome.

thanks in advance

SCJP 1.4
SCWCD

Ulf Dittmer

Rancher

Posts: 42969

73

posted 7 years ago

For starters, if the applet is signed properly, then there is no need for any policy changes. Signing the applet confers all right to it.

Secondly, the browser JRE will not know about any security policy file changes unless you make them to the policy file that governs that particular JRE. Looks through its installation directories to find its policy file.

Lastly, it's always a bit of a gamble what happens if an applet is started by double-clicking an HTML file. Put the HTML and applet on a web server, and start it properly through its web page. That'll be a more reliable indicator of what happens in a real environment.

thanks for the reply. I followed the process what u've said. But still it doesn't work. I'm getting the same exception. I followed the way for signing applet jar as described in "http://java.sun.com/developer/onlineTraining/Programming/JDCBook/signed.html" then i've put the jar where my signedApplet.html is located. I've written following code in signedApplet.html "<html> <body> <applet height="271" width="226" code="JFileChooserTest" archive="SUploadFilesApplet.jar,lib/commons-httpclient-2.0.jar,lib/commons-logging-1.1.1.jar">

</applet> </body>

</html>"

Is that because of self-signed application? I've also uploaded the CompanyCer.cer in my IE.