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? Commented Apr 27, 2011 at 20:41
  • 3
    Post the relevant code (and maybe accept some answers?) Commented 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.

Sign up to request clarification or add additional context in comments.

Comments

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?

Comments

1

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

Comments

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";

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.