user1022570
user1022570

Reputation: 71

Java Applet File Permission Errors

This exception occurs when I want to access a PDF file and print it:

java.security.AccessControlException: access denied (java.io.FilePermission write)

To access file and print is all within one function and I am using JS/PHP button to access this applet function. The applet and JS/PHP work communicating between each other. There was a read fileDFpermissionexception before but I figured I can use the File class method setReadable(true); and that worked.

Unfortunately setWritable(true) does not. I have also included a policy file and signed my jar, so I am not sure whats going on here. I have read little so far but perhaps this code can help me?:

java.security.PrivilegedAction() { public Object run() {

Not even sure what it does so any help with this question would be great

Upvotes: 0

Views: 477

Answers (1)

Andrey Nudko
Andrey Nudko

Reputation: 707

You're looking into right direction - actions that requier an approval from SecurityManager (like file operations) should be executed from PrivilegedAction in applets. Then if all the code is trusted (signed and certificate installed in browser), that would work.

Upvotes: 1

Related Questions