3

Exception in thread "AWT-EventQueue-1" java.security.AccessControlException: acc ess denied (java.io.FilePermission write)

i am getting the above error when i tried to write into a file.

what i need to do kindly help out...

i am running an applet application...

2
  • 2
    Have you tried signing your applet? Apr 27, 2011 at 20:41
  • 3
    Post the relevant code (and maybe accept some answers?)
    – Jeremy
    Apr 27, 2011 at 20:42

4 Answers 4

6

Applets are by default denied from accessing the client's file I/O. You need to sign your applet or edit the policy files.

2

As far as i know Applets cannot write to files as this would be a security violation. You can expressly grant the file-writing permission to the JVM to enable this but i think that would be a really bad idea because your users would be allowing you to write whatever you wanted to their disk via the web. Why does your applet want to write to a file?

1

Is your applet signed? Non signed applets can't access files. See here: http://java.sun.com/developer/onlineTraining/Programming/JDCBook/signed.html

0

Do like this:

 fos=AccessController.doPrivileged(new PrivilegedAction()
    public  FileOutputStream run() {
      return new FileOutputStream(f1);
    }
  });

or edit file "java.policy" add permission java.io.FilePermission "<<ALL FILES>>", "read,write";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.