Results 1 to 7 of 7
  1. #1
    DaanDwars is offline Member
    Join Date
    Sep 2009
    Location
    Amsterdam, The Netherlands
    Posts
    3
    Rep Power
    0

    Default Applet: Can't write a file

    Dear Members,


    I have made an FreeCell-game-applet that works, but I want it to write text files so that it can *learn* from human mistakes. Sorry administration does not allow me to post the link.


    Now when I compile and run my applet in eclipse, it works fine, but as soon as I put it in a separate directory, either on a server or local, and run it WITHOUT eclipse, I get this error:


    Exception in thread "AWT-EventQueue-3" java.security.AccessControlException: access denied (java.io.FilePermission 1251970144054_sequence.txt write)


    Any help would be appreciated.


    Sincerely,


    Daan van den Berg
    Amsterdam

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Did you check that what's the error AccessControlException in Java doc? If you can read it, you can have a better idea what you've done in wrong way.

  3. #3
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Applets are naughty little things that are presumed guilty until proven innocent.
    You need to sign your applet to prove that it is indeed innocent and allow it to access delicate things like the file system or databases.
    Why does it need to be an applet and not a normal Java application? Why not serve the application using webstart if you want it to be available over the web?
    Last edited by r035198x; 09-03-2009 at 01:15 PM.

  4. #4
    DaanDwars is offline Member
    Join Date
    Sep 2009
    Location
    Amsterdam, The Netherlands
    Posts
    3
    Rep Power
    0

    Default

    @both

    Thanks for your replies.



    @ Eranga

    Done that. I'm sure it has something to do with this: "...or request access that is not allowed according to the security policy...". But I'm alsoconvinced it's in the JAVA-code.


    @r035198x

    I think signing is only necessary if you open my webpage and the including applet and want to allow it to write to YOUR directory. You then have to "accept the certificate". In this case I want it to write simply into the directory it is started from in the first place.


    Daan
    Last edited by DaanDwars; 09-03-2009 at 01:58 PM. Reason: [correction]

  5. #5
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Quote Originally Posted by DaanDwars View Post
    @both

    ...

    @r035198x

    ...In this case I want it to write simply into the directory it is started from in the first place.


    Daan
    ... and which directory is that? Remember Applets run in the browser on the client.

  6. #6
    DaanDwars is offline Member
    Join Date
    Sep 2009
    Location
    Amsterdam, The Netherlands
    Posts
    3
    Rep Power
    0

    Default

    Hmmm ... you're right.

    But loading files works, but that might have to do with the call GetDocumentBase().


    Would you say it makes more sense to ask: "how can I write a text file to a specific location on the web?" by the latter meaning my own directory on the server?


    Daan

  7. #7
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    You are best to use a servlet and run this as a web application or read my first response again.

Similar Threads

  1. Signed Applet to write on LPT1 port - permission error
    By ConvoyTh in forum Java Applets
    Replies: 0
    Last Post: 07-02-2009, 11:56 AM
  2. Write to a file in a jar
    By Ms.Ranjan in forum New To Java
    Replies: 4
    Last Post: 06-12-2009, 10:27 PM
  3. Replies: 5
    Last Post: 02-05-2009, 11:28 AM
  4. [SOLVED] File Write in File
    By Eku in forum New To Java
    Replies: 4
    Last Post: 10-27-2008, 05:01 AM
  5. Write to file
    By esadeghi in forum Advanced Java
    Replies: 1
    Last Post: 05-21-2008, 02:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •