Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2011
    Posts
    6
    Rep Power
    0

    Default Java.security.AccessControlException

    Hai all,

    I am developing an applet which performs the Pinging operation using command prompt.

    Here I am giving the Code of my applet.

    import java.awt.*;
    import javax.swing.*;
    import java.applet.*;
    import java.io.*;
    import java.awt.event.*;
    public class applet1 extends Applet implements ActionListener{
    String str;
    public static TextArea area;
    public static TextField ipaddress;
    public void init(){
    str = "this is my first Applet";
    Label label = new Label("Enter IP Address");
    add(label);
    ipaddress = new TextField(20);
    add(ipaddress);
    Button submit = new Button("Ping");
    add(submit);
    area = new TextArea(20,40);
    add(area);
    submit.addActionListener(this);
    setBackground(Color.gray);
    }
    public void paint(Graphics g){
    showStatus("pinging.....");
    }
    public void actionPerformed(ActionEvent ae){
    String ip = ipaddress.getText();
    String pingResult = "";
    String pingCmd = "ping " + ip;
    try {
    Runtime r = Runtime.getRuntime();
    Process p = r.exec(pingCmd);
    BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String inputLine = null;
    while ((inputLine = in.readLine()) != null) {
    area.append(inputLine+"\n");
    pingResult += inputLine;
    }
    in.close();
    }
    catch (IOException e) {
    System.out.println(e);
    }
    }
    }




    This code is generating an exception as shown in the image.



    [IMG][/IMG]Java.security.AccessControlException-exception.png


    Can anybody fix this for me?

    Thanks in advance.
    Last edited by ramanareddy438; 12-12-2011 at 01:50 PM.

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: Java.security.AccessControlException

    Applets have security controls to protect client computers...see the following:
    What Applets Can and Cannot Do (The Java™ Tutorials > Deployment > Java Applets)
    In other words, sign the applet

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default Re: Java.security.AccessControlException

    You'll need to sign the jar.
    Applets work in their own little security box such that they are not allowed to do anything much with the underlying system (like launch random commands).

  4. #4
    Join Date
    Dec 2011
    Posts
    6
    Rep Power
    0

    Default Re: Java.security.AccessControlException

    Thanks for posting the reply........


    So finally what i have to do to execute the program......


    please help me.........................

  5. #5
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: Java.security.AccessControlException

    Quote Originally Posted by ramanareddy438 View Post
    So finally what i have to do to execute the program.......
    Help you how? What is your question? Did you read the posts above? You have to sign the jar. Did you research how to do this? If so and you are confused, what are you confused about?

Similar Threads

  1. java.security.AccessControlException in Applet
    By gopimano in forum New To Java
    Replies: 0
    Last Post: 12-07-2010, 10:57 AM
  2. How to solve java.security.AccessControlException
    By chyrl in forum Advanced Java
    Replies: 0
    Last Post: 09-24-2010, 08:49 PM
  3. java.security.AccessControlException
    By cecily in forum Java Applets
    Replies: 1
    Last Post: 08-06-2007, 02:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •