13 Replies Latest reply: Sep 16, 2010 11:29 AM by 843811 RSS

    java.security.AccessControlException

    843811
      I have a Minesweeper program (GUI) that I turned into an applet so I could put on online. I basically just copied the body of the constructor into the init() method. After fixing a few things, I ran the program and I got this. Just for clarification, "normal.gif" is one of the pictures I have.
      java.security.AccessControlException: access denied (java.io.FilePermission normal.gif read)
           at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
           at java.security.AccessController.checkPermission(AccessController.java:546)
           at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
           at java.lang.SecurityManager.checkRead(SecurityManager.java:871)
           at sun.awt.SunToolkit.getImageFromHash(SunToolkit.java:871)
           at sun.awt.SunToolkit.getImage(SunToolkit.java:885)
           at javax.swing.ImageIcon.<init>(ImageIcon.java:110)
           at javax.swing.ImageIcon.<init>(ImageIcon.java:136)
           at Minesweeper.start(Minesweeper.java:132)
           at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Plugin2Manager.java:1639)
           at java.lang.Thread.run(Thread.java:619)
      Exception: java.security.AccessControlException: access denied (java.io.FilePermission normal.gif read)
      Below is the html code I used.
      <html>
      <head></head>
      <body>
      <Applet Code="Minesweeper.class" WIDTH="285" HEIGHT="331">
      </Applet>
      </body>
      </html>
      Edited by: Vistz on Sep 15, 2010 6:55 PM
        • 1. Re: java.security.AccessControlException
          EJP
          This forum is about signed applets. Is this a signed applet?
          • 2. Re: java.security.AccessControlException
            793415
            Vistz wrote:
            ...After fixing a few things, I ran the program and I got this. ...
            Uh-huh. If you should have any questions on that, feel free to pop back by and ask them.
            • 3. Re: java.security.AccessControlException
              843811
              ejp wrote:
              This forum is about signed applets. Is this a signed applet?
              I don't think so. Sorry, I think I misread the forum name.

              Edited by: Vistz on Sep 15, 2010 7:23 PM
              • 4. Re: java.security.AccessControlException
                843811
                AndrewThompson64 wrote:
                Vistz wrote:
                ...After fixing a few things, I ran the program and I got this. ...
                Uh-huh. If you should have any questions on that, feel free to pop back by and ask them.
                I just fixed a few things concerning the panels. My original class extended JPanel. Since I am now extending Applet, I had to create a new JPanel object which would serve as the main panel.

                Edited by: Vistz on Sep 15, 2010 7:23 PM
                • 5. Re: java.security.AccessControlException
                  843811
                  Sorry about posting in the wrong forum. Would it be possible to have this moved to the appropriate forum so that my question can be answered accurately?
                  • 6. Re: java.security.AccessControlException
                    793415
                    Vistz wrote:
                    Sorry about posting in the wrong forum. Would it be possible to have this moved to the appropriate forum so that my question can be answered accurately?
                    It is certainly possible to have a thread moved. Note though, that the question quoted in my reply is the 1st question you have asked in this thread.

                    Recommended reading - [How To Ask Questions The Smart Way: Be explicit about your question|http://catb.org/esr/faqs/smart-questions.html#explicit].
                    • 7. Re: java.security.AccessControlException
                      843811
                      AndrewThompson64 wrote:
                      Vistz wrote:
                      Sorry about posting in the wrong forum. Would it be possible to have this moved to the appropriate forum so that my question can be answered accurately?
                      It is certainly possible to have a thread moved. Note though, that the question quoted in my reply is the 1st question you have asked in this thread.

                      Recommended reading - [How To Ask Questions The Smart Way: Be explicit about your question|http://catb.org/esr/faqs/smart-questions.html#explicit].
                      The first line of the stack trace reads
                      java.security.AccessControlException: access denied (java.io.FilePermission normal.gif read))
                      //normal.gif is the name of the picture file I am using
                      I was wondering if there was some code I should have added to my applet to fix this.
                      • 8. This Thread is now moved
                        DarrylBurke
                        Note: This thread was originally posted in the [Signed Applets|http://forums.sun.com/forum.jspa?forumID=63] forum, but moved to this forum for closer topic alignment.
                        • 9. Re: java.security.AccessControlException
                          EJP
                          The answer to your question is to sign the applet. That's why I was asking about why you were in that forum. You were in the right forum with the wrong question.
                          • 10. This Thread is now moved
                            EJP
                            Note: This thread was originally posted in the [Java Applet Development|http://forums.sun.com/forum.jspa?forumID=421] forum, but moved to this forum for closer topic alignment.

                            @DB you missed the point ;-)
                            • 11. Re: java.security.AccessControlException
                              843811
                              Vistz wrote:
                              My original class extended JPanel. Since I am now extending Applet, I had to create a new JPanel object which would serve as the main panel.
                              Applet and JPanel ! Surely you mean JApplet and JPanel ?
                              • 12. Re: java.security.AccessControlException
                                843811
                                sabre150 wrote:
                                Vistz wrote:
                                My original class extended JPanel. Since I am now extending Applet, I had to create a new JPanel object which would serve as the main panel.
                                Applet and JPanel ! Surely you mean JApplet and JPanel ?
                                I'm using Applet currently. Is JApplet a better choice?
                                • 13. Re: java.security.AccessControlException
                                  843811
                                  Vistz wrote:
                                  sabre150 wrote:
                                  Vistz wrote:
                                  My original class extended JPanel. Since I am now extending Applet, I had to create a new JPanel object which would serve as the main panel.
                                  Applet and JPanel ! Surely you mean JApplet and JPanel ?
                                  I'm using Applet currently. Is JApplet a better choice?
                                  Mixing lightweight components (Swing) with heavyweight components (AWT) is not a good idea. I understand that with Java 7 that might be OK but I haven't met a situation where is makes sense. Of course someone will now point out a situation where the mixing makes sense.