• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.security.AccessControlException: access denied

 
Harsha Ravnikar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,
I get a security exception when I redefine line seperator. Can any body help me out? I'll be greatful.
Regards,
Harsha

public void init()
{
///////////////// Redefine line seperator here ///////////////////
Properties sysProp = System.getProperties();
String lineprop = sysProp.getProperty("line.separator");
sysProp.put("line.separator","\n");
System.setProperties(sysProp);
///////////////// End redefining line seperator //////////////////
setLayout(new BorderLayout());
text = new TextArea(7,35);
add("North", text);
add("South", new Label("To be run on Netscape 4.7"));
Font newFont = new Font("serif",Font.PLAIN,26);
text.setFont(newFont);
resize(350, 300);
text.requestFocus();
}
AppletViewer displays this message ....
*******************************
java.security.AccessControlException: access denied (java.util.PropertyPermission * read,write)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java, Compiled Code)
at java.security.AccessController.checkPermission(AccessController.java, Compiled Code)
at java.lang.SecurityManager.checkPermission(SecurityManager.java, Compiled Code)
at java.lang.SecurityManager.checkPropertiesAccess(SecurityManager.java:1215)
at java.lang.System.getProperties(System.java:484)
at kannada_av.init(kannada_av.java:65)
at sun.applet.AppletPanel.run(AppletPanel.java:333)
at java.lang.Thread.run(Thread.java:479)
*******************************
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are trying to set a System configuration parameter from an Applet. There is a security manager to prevent Applets from changing System parameters, This is to provide you security from rouge Applets on the web. If you ran this as an application without a security manager, it compiles and runs fine.
 
John Wayne
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nice explanation Carl, but how about helping him out a little bit with how he might get it to work instead of a winded reason of why it doesn't. This isn't a forum to share your extent of Java knowledge as to why something doesn't work but rather a place for like minded and helpful Java developers to assist and be assisted in their various Java excursions.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ummm... Carl did provide a possible solution. It may or may not be satisfactory in this case, depending on just what Harsha is trying to do. Does the program have to be an Applet? If so, I don't know any way to redefine the line separator. (Personally, I almost never use Applets.) Maybe it's possible to reset the security permissions for what Applets are allowed to do - but I'm sure that can't be done by the Applet itself, so this may also be unworkable for Harsha. The question then becomes - why does that line separator need to be redefined, and how is it being used - there may be a way to work around that. One way is to never use println() or similar methods which rely on the system line separator - instead write the separator you want yourself. E.g.
<code><pre> System.out.print("Hi!\n");</pre></code>
rather than
<code><pre> System.out.println("Hi!");</pre></code>
"John", you should realize that none of us has an infinite amount of time, and we don't know everything. If we have some information which can help someone, and we have time to share it, we do so. We aren't under any obligation to provide a complete solution if we don't know one or don't have time for it. The benefit of having a large number of posters is that chances are, if a solution exists, someone else can build on what you post and eventually you may reach the desired solution. That's assuming that the other posters aren't put off by whiny, ungrateful people who are miffed that they didn't get the answer they wanted right away.
[This message has been edited by Jim Yingst (edited June 06, 2001).]
 
Junilu Lacar
Bartender
Pie
Posts: 7273
44
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did the Duke get reincarnated as a troll?
killList.add("John Wayne");
 
Harsha Ravnikar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,
I never got any reply to that post. Then on, dint really hang around this place for long. Good we get an email notification whenever a post is answered. Nice feature.
At that time, I was manipulating text as and when it was being entered. But there is a bug in java.awt.TextArea in JVM 1.1.5 by which we get incorrect caret position problem. And I was in the process of figuring it out. BUt now I have a beautiful fix for that which I always use as an replacement for java.awt.TextArea when ever Java Plugin is not an option
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic