Forum Stats

  • 3,783,738 Users
  • 2,254,825 Discussions
  • 7,880,524 Comments

Discussions

How do i use the SecurityManager?

843811
843811 Member Posts: 49,851
I am trying to have an applet display an html page in a JEditorPane, but the applet fails because of AccessControlException. Do i need to use a SecurityManager? If so, how do i go about implemeting it in my code?
Thank you in advance!

Tarek

Comments

  • 843811
    843811 Member Posts: 49,851
    Hi Tarek,

    In order to avoid this exception, you have to specify the required permission for the specified file by means of policy tool.

    1) Start the policy tool

    2) Grant the required permission

    3) Save the policy file.

    Then while starting the appletviewer it can be given as

    appletviewer -J-Djava.security.policy=mypolicy
    http://java.sun.com/WriteFile.html.


    Lot of examples are given in the security tutorial of sun site.

    I hope this will help you.

    Thanks
    Bakrudeen
    Technical Support Engineer
    Sun MicroSystems Inc, India
  • 843811
    843811 Member Posts: 49,851
    Hi Bakrueddine,

    I changed the java.policy file and added the following,

    permission java.net.SocketPermission "*:80","connect,accept";

    the error i am getting is:

    java.security.AccessControlException: access denied (java.net.SocketError www.sitename.com resolve)


    What does that exception mean?

    Thanks in advance,

    Tarek
This discussion has been closed.