Results 1 to 6 of 6
  1. #1
    Agri is offline Member
    Join Date
    Sep 2008
    Posts
    7
    Rep Power
    0

    Default Write access for downloading file.

    Hello,

    My Java Applet connects with software I have made which runs on Windows PC's. The problem I am having is with windows vista (have not tested XP yet). My applet downloads a file to a sub directory of C:\Program Files\. In vista this requires Admin rights to write to, so Internet Explorer must be run as an Admin so the applet can right there else I get.

    java.io.FileNotFoundException: (Access is denied)

    Is there a way to let to get around this sort of problem without having to run as admin?

    Thanks,

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,556
    Rep Power
    23

    Default

    Your applet needs to be given permission to access a local file.
    To give an applet permission, you need to either sign the jar file the applet is in or create an entry in the .java.policy file on the PC that the applet executes on.

  3. #3
    Agri is offline Member
    Join Date
    Sep 2008
    Posts
    7
    Rep Power
    0

    Default

    The applet is signed. When I run it in netbeans IDE java does not give out any errors and in the console Java claims to have written the file, but it has actually not. Where abouts is this policy file? I would prefer to not have to get the users to make changes to their computers by installing/changing anything, but rather just visit the webpage and let the applet do everything.

    Cheers,

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,556
    Rep Power
    23

    Default

    Are there any error messages in the java console? Copy and paste them here.
    When I run it in netbeans IDE java does not give out any errors
    What happens when you run it in a browser reading an HTML file from your PC? id est locally not via a server?
    Use a signed jar file to keep the user from having to change anything.

  5. #5
    Agri is offline Member
    Join Date
    Sep 2008
    Posts
    7
    Rep Power
    0

    Default

    Ok,

    Run In netbeans = No java errors in console, just no file.
    Run from HTML file in browser = No java errors in console, just no file.
    Run from HTML file through browser from webserver = Error.

    Java Code:
    java.io.FileNotFoundException: C:\Program Files\directory\image.png (Access is denied)
    	at java.io.FileOutputStream.open(Native Method)
    	at java.io.FileOutputStream.<init>(Unknown Source)
    	at java.io.FileOutputStream.<init>(Unknown Source)
    	at b.download(b.java:49)
    	at a.paint(a.java:83)
    	at sun.awt.RepaintArea.paintComponent(Unknown Source)
    	at sun.awt.RepaintArea.paint(Unknown Source)
    	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
    	at java.awt.Component.dispatchEventImpl(Unknown Source)
    	at java.awt.Container.dispatchEventImpl(Unknown Source)
    	at java.awt.Component.dispatchEvent(Unknown Source)
    	at java.awt.EventQueue.dispatchEvent(Unknown Source)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.run(Unknown Source)
    This error does not appear when Internet Explorer is run as an admin, all the above tests were with a signed applet.

    How can this be fixed?

    Thanks,

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,556
    Rep Power
    23

    Default

    Run from HTML file in browser = No java errors in console, just no file.
    I have absolutely no idea how this can happen. Do you know where the java console for your browser is?

    Change your program to output messages with println() before and after the file is written.
    Then run it from an HTML file and Copy and paste the contents of the java console here?

Similar Threads

  1. how to write onto a file
    By mirage_87 in forum New To Java
    Replies: 6
    Last Post: 09-08-2009, 03:54 PM
  2. Replies: 1
    Last Post: 05-30-2008, 10:33 PM
  3. Write to file
    By esadeghi in forum Advanced Java
    Replies: 1
    Last Post: 05-21-2008, 01:13 PM
  4. File Write Error
    By vikain in forum Advanced Java
    Replies: 5
    Last Post: 01-02-2008, 04:38 AM
  5. Help with write file in java
    By mathias in forum New To Java
    Replies: 1
    Last Post: 07-31-2007, 06:51 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
  •