wood burning stoves 2.0*
The moose likes Applets and the fly likes help!!! java.security.access controlException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "help!!! java.security.access controlException" Watch "help!!! java.security.access controlException" New topic
Author

help!!! java.security.access controlException

ganeshjk krishnamurthy
Greenhorn

Joined: Apr 30, 2004
Posts: 8
hi,
I am creating an applet using swing.I am working on linux.
In the code below , when I click on JComboBox CB1 and consequently call the dut.show() method I get the following exception
"java.security.AccessControlException access denied (java.io.FilePermission /home/ganesh/test/j2sdk_nb/bin read)
at java.security.AccessController.checkPermission(AccessControlContext java :line number)
and so on ....................."
I checked the directory for permissions and found them to be ok.
Please suggest a solution to overcome this issue.
regards,
ganesh.
public class HelloWorld2 extends JApplet implements ActionListener {

JFrame a = new JFrame("Deembed");
String data[] = { "trans" , "ind" , "kap" , "line" , "none"};

FileDialog open_file = new FileDialog(a, "-open" , FileDialog.LOAD);
FileDialog thr = new FileDialog(a, "-short - thru" , FileDialog.LOAD);
FileDialog dut = new FileDialog(a, "DUT" , FileDialog.LOAD);
JComboBox CB2 = new JComboBox();
public void init()
{
JComboBox CB1 = new JComboBox(data);

CB1.addActionListener(this);
CB2.addActionListener(this);

this.getContentPane().add(CB1);
this.getContentPane().add(CB2);
this.getContentPane().setLayout(new FlowLayout());
}
public void actionPerformed(ActionEvent e) {

JComboBox cb = (JComboBox)e.getSource();
// String data1 = (String)cb.getSource();
System.out.println(cb.getSelectedItem());
//process : Add data to CB2
if(cb.getSelectedItem() == "ind" ) {
CB2.removeAllItems();
CB2.addItem("-ind");
CB2.addItem("none");

dut.show();
}
else if (cb.getSelectedItem() == "kap"){
CB2.removeAllItems();
CB2.addItem("-kap");
CB2.addItem("none");

dut.show();
}
else if ( cb.getSelectedItem() == "trans"){
CB2.removeAllItems();
CB2.addItem("-e");
CB2.addItem("-c");
CB2.addItem("-ipol");
CB2.addItem("-l");
CB2.addItem("none");

dut.show();
}
else if ( cb.getSelectedItem() == "line"){
CB2.removeAllItems();
CB2.addItem("-line");
CB2.addItem("none");

dut.show();
}


}
}
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Applets are not allowed to access the local filesystem of the client PC without the proper permissions, (usually this means you need to sign your jar file).
I am moving this to the Applets forum since you are't having a problem with the SWING GUI portion of the code.


GenRocket - Experts at Building Test Data
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
As Gregg said, Applets run in the "sandbox" with very limited access to system resources. The fact that the file permissions are set correctly doesn't do anything for you. The easiset way to handle this is to add a permission to the plugin policy file, java.policy, which is located in the lib/security subdirectory of the plugin's main directory. If your applet's codebase is http://www.mysite.com then you would add an entry like:

That will allow unfettered access to all system resources, which may not be what you want. You can limit it to specific permissions by using different permission types for example:

That would grant read permission to just the file "/home/ganesh/test/j2sdk_nb/bin.


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
ganeshjk krishnamurthy
Greenhorn

Joined: Apr 30, 2004
Posts: 8
Originally posted by Michael Morris:
As Gregg said, Applets run in the "sandbox" with very limited access to system resources. The fact that the file permissions are set correctly doesn't do anything for you. The easiset way to handle this is to add a permission to the plugin policy file, java.policy, which is located in the lib/security subdirectory of the plugin's main directory. If your applet's codebase is http://www.mysite.com then you would add an entry like:

That will allow unfettered access to all system resources, which may not be what you want. You can limit it to specific permissions by using different permission types for example:

That would grant read permission to just the file "/home/ganesh/test/j2sdk_nb/bin.
ganeshjk krishnamurthy
Greenhorn

Joined: Apr 30, 2004
Posts: 8
hi,
Sorry for the previous message posted( was a bit careless).
Thanks a lot for guiding me.But as I am quite new to java please tell me what is this plugin you are talking about ? Also I found a java.policy file in the following path C:\Program Files\j2sdk_nb\j2sdk1.4.2\jre\lib\security.
Is it this java.policy file which I have to edit with the code you gave me ? Can I set the read permission for the whole directory ?
thanks in advance
ganesh.
 
Don't get me started about those stupid light bulbs.
 
subject: help!!! java.security.access controlException