Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Java.security.AccessControlException

  1. #1
    Junior Member
    Join Date
    Dec 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.



    Java.security.AccessControlException-exception.png


    Can anybody fix this for me?step3b_fail.jpg

    Thanks in advance.
    Last edited by ramanareddy438; December 13th, 2011 at 05:57 AM.

  2. #2
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: Java.security.AccessControlException

    Java.security.AccessControlException-exception.png
    Why don't you try reading about the exception? You don't have access by OS to do this.

  3. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

  4. #4
    Member
    Join Date
    Nov 2011
    Posts
    39
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Java.security.AccessControlException

    The default permissions for applet is very limited, so you should either have a .java.policy file or sign the applet using a certificate to give it the required permission.

    Spring 3
    Last edited by cafeteria84; January 22nd, 2012 at 04:05 PM.

Similar Threads

  1. Java Security Implementation for Plugin Supported Architecture
    By bgroenks96 in forum Java Theory & Questions
    Replies: 19
    Last Post: November 22nd, 2011, 04:13 PM
  2. AccessControlException caused by getCodeBase().getHost()
    By DarthCoffee in forum What's Wrong With My Code?
    Replies: 0
    Last Post: March 15th, 2011, 06:38 PM
  3. RSA Decryption with Java.security - Hex to dec to byte array conversion...
    By SeanSeanston in forum What's Wrong With My Code?
    Replies: 0
    Last Post: December 15th, 2010, 09:48 AM
  4. sign XML with WS-Security
    By splendes in forum Java SE APIs
    Replies: 1
    Last Post: October 6th, 2010, 08:49 AM
  5. Jar File Security
    By Symbols in forum Java Theory & Questions
    Replies: 1
    Last Post: February 28th, 2010, 10:48 PM