Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 3 of 3 FirstFirst 123
Results 51 to 65 of 65

Thread: Access Denied!

  1. #51
    Member
    Join Date
    Feb 2013
    Posts
    40
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Access Denied!

    I have figured out the problem.
    I had a folder with the exact same name for no reason.

    Also, now with that working, do I have to have all users of my applet to have the same .java.policy file as me?

  2. #52
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    24,186
    Thanks
    63
    Thanked 2,577 Times in 2,547 Posts

    Default Re: Access Denied!

    That would be one solution, but not a good one. If you have to go that way you'd need to set the codeBase to restrict permissions.

    Try signing the jar file.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #53
    Member
    Join Date
    Feb 2013
    Posts
    40
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Access Denied!

    I don't understand the link you gave to me about signing jars.

  4. #54
    Member
    Join Date
    Feb 2013
    Location
    earth
    Posts
    88
    Thanks
    12
    Thanked 9 Times in 9 Posts

    Default Re: Access Denied!

    G

  5. #55
    Member
    Join Date
    Feb 2013
    Posts
    40
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Access Denied!

    When I've googled how it says to use jar signer but it gives the error of:
    Error: Could not find or load main class sun.security.tools.JarSigner

  6. #56
    Junior Member
    Join Date
    Mar 2015
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Access Denied!

    Quote Originally Posted by Norm View Post
    My applets that require permission are only executed on my pc. I use the .java.policy file to grant permissions.
    Here is a sample of my .java.policy file:
    I use the policytool to edit it. It is located in the user.dir folder.
    Hello, Norm.

    I have tried this, but it did not help me, unfortunately. The same "access denied" message is shown in java-console.

    Does it work at all with unsigned applets?

    Thanx.

  7. #57
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    24,186
    Thanks
    63
    Thanked 2,577 Times in 2,547 Posts

    Default Re: Access Denied!

    Post the contents of the .java.policy file and its location on your PC. Are you sure the .java.policy file is being used?

    I have several local, unsigned applets that are able to read and write files on my PC. I have also put them in the Control Panel's Java Item's Exception Site list.
    If you don't understand my answer, don't ignore it, ask a question.

  8. #58
    Junior Member
    Join Date
    Mar 2015
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Access Denied!

    Quote Originally Posted by Norm View Post
    Post the contents of the .java.policy file and its location on your PC. Are you sure the .java.policy file is being used?

    I have several local, unsigned applets that are able to read and write files on my PC. I have also put them in the Control Panel's Java Item's Exception Site list.
    -----------------------------------------------------------------------------------------------------------
    .java.policy contents:
    -----------------------------------------------------------------------------------------------------------
    // Standard extensions get all permissions by default

    grant codeBase "file:${{java.ext.dirs}}/*" {
    permission java.security.AllPermission;
    };

    // default permissions granted to all domains

    grant {
    // Allows any thread to stop itself using the java.lang.Thread.stop()
    // method that takes no argument.
    // Note that this permission is granted by default only to remain
    // backwards compatible.
    // It is strongly recommended that you either remove this permission
    // from this policy file or further restrict it to code sources
    // that you specify, because Thread.stop() is potentially unsafe.
    // See the API specification of java.lang.Thread.stop() for more
    // information.
    permission java.lang.RuntimePermission "stopThread";

    // allows anyone to listen on dynamic ports
    permission java.net.SocketPermission "localhost:0", "listen";

    // "standard" properies that can be read by anyone

    permission java.util.PropertyPermission "java.version", "read";
    permission java.util.PropertyPermission "java.vendor", "read";
    permission java.util.PropertyPermission "java.vendor.url", "read";
    permission java.util.PropertyPermission "java.class.version", "read";
    permission java.util.PropertyPermission "os.name", "read";
    permission java.util.PropertyPermission "os.version", "read";
    permission java.util.PropertyPermission "os.arch", "read";
    permission java.util.PropertyPermission "file.separator", "read";
    permission java.util.PropertyPermission "path.separator", "read";
    permission java.util.PropertyPermission "line.separator", "read";

    permission java.util.PropertyPermission "java.specification.version", "read";
    permission java.util.PropertyPermission "java.specification.vendor", "read";
    permission java.util.PropertyPermission "java.specification.name", "read";

    permission java.util.PropertyPermission "java.vm.specification.version", "read";
    permission java.util.PropertyPermission "java.vm.specification.vendor", "read";
    permission java.util.PropertyPermission "java.vm.specification.name", "read";
    permission java.util.PropertyPermission "java.vm.version", "read";
    permission java.util.PropertyPermission "java.vm.vendor", "read";
    permission java.util.PropertyPermission "java.vm.name", "read";
    };

    grant codeBase "file:/D:/username/IdeaProjects/-" {
    permission java.io.FilePermission "D:/username/IdeaProjects/SimpleAppletTest/out/production/SimpleAppletTest/01.wav", "read";
    };
    -----------------------------------------------------------------------------------------------------------
    location of .java.policy: D:\Program Files\jdk-8u20-windows-x64\jre\lib\security\java.policy
    -----------------------------------------------------------------------------------------------------------

    No, i am not sure, that this file is used. How to check it? Actually, i did not create it myself. It already existed, and i just added a few strings to it as you have wrote in this thread.

    Locations of .class, .html and .wav are all the same: D:\username\IdeaProjects\SimpleAppletTest\out\prod uction\SimpleAppletTest

    Also, .html is added to Exception Site List. But i still got that stacktrace in java console:
    java.security.AccessControlException: access denied ("java.io.FilePermission" "D:\username\IdeaProjects\SimpleAppletTest\out\pro duction\SimpleAppletTest\01.wav" "read")

  9. #59
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    24,186
    Thanks
    63
    Thanked 2,577 Times in 2,547 Posts

    Default Re: Access Denied!

    That does not look like the right location for the file.
    Mine is at: C:\Users\Norm\.java.policy

    It's usually better not to change files inside of the JDK's folders. Any changes could be lost on the next JDK update.

    Is that the file that is opened when you execute the policytool program?
    If you don't understand my answer, don't ignore it, ask a question.

  10. #60
    Junior Member
    Join Date
    Mar 2015
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Access Denied!

    When i open command line and enter "policytool" i see this.
    policytool.jpg

    Does it mean, that actually i have no policy files, that are used by my browser when i launch an applet?

  11. #61
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    24,186
    Thanks
    63
    Thanked 2,577 Times in 2,547 Posts

    Default Re: Access Denied!

    Fill in the fields and save the .java.policy file using the policytool.
    I don't know if the browser will look anywhere else.

    Also check for the correct format for the Control Panel's Java Item Exception Site list.
    If you don't understand my answer, don't ignore it, ask a question.

  12. #62
    Junior Member
    Join Date
    Mar 2015
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Access Denied!

    I've done it. The policytool generated a file with this content:

    /* AUTOMATICALLY GENERATED ON Fri Mar 13 20:44:28 MSK 2015*/
    /* DO NOT EDIT */

    grant codeBase "file:/D:/username/IdeaProjects/-" {
    permission java.io.FilePermission "<<ALL FILES>>", "read";
    };

    But java console still shows the same exception. How do I understand that the policy file, that i have created is used by my browser? And does it matter where to save my own java.policy file?

    I'm sure that format for the Control Panel's Java Item Exception Site list is correct, because my applet works in browser and shows text. If the format was incorrect the applet would not launched.

  13. #63
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    24,186
    Thanks
    63
    Thanked 2,577 Times in 2,547 Posts

    Default Re: Access Denied!

    How do I understand that the policy file, that i have created is used by my browser?
    The only way I've found is when it works
    and then a change to it stops it from working.
    Version A works
    Version B does not work
    If you don't understand my answer, don't ignore it, ask a question.

  14. #64
    Junior Member
    Join Date
    Mar 2015
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Access Denied!

    Ok. I got one version. What are yours user.home, java.home and user.dir ? May be the location of java.policy matters? I just want to compare values of yours variables with the location of java.policy file.

  15. #65
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    24,186
    Thanks
    63
    Thanked 2,577 Times in 2,547 Posts

    Default Re: Access Denied!

    May be the location of java.policy matters?
    Yes it does. As I said, mine is in user.dir
    Note: the filename is .java.policy (has leading .)
    If you don't understand my answer, don't ignore it, ask a question.

Page 3 of 3 FirstFirst 123

Similar Threads

  1. Read Permission Problem -Access Denied
    By ocean1991 in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: December 28th, 2012, 09:38 AM
  2. Local Domain MySQL server, access denied
    By techwiz24 in forum JDBC & Databases
    Replies: 1
    Last Post: February 29th, 2012, 10:29 PM
  3. [SOLVED] Access Denied when extracting zip file.
    By techwiz24 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 18th, 2011, 06:50 PM
  4. JFileChooser save dialog box "access is denied" error
    By byrdman in forum What's Wrong With My Code?
    Replies: 7
    Last Post: August 2nd, 2011, 01:45 PM
  5. Replies: 6
    Last Post: August 18th, 2010, 05:41 PM

Tags for this Thread