Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

appletviewer

 
balakrishna
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello everybody
i have noted from the corejava 1 from sun publishing that an applet which runs an application programme of the local system will work,and the problem only arises if u try to run it with the browser. i have the following applet which tries to open note pad(winnt!!). the program is compiling fine but is throwing security exception when the button is pressed.
can any body please explain it
//30.07.2000
//security??
/* <applet code="NewAp1.class" height=200 width=400></applet>*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class NewAp1 extends Applet
{

public void init()
{
//setLayout(new FlowLayout());

Button b=new Button("notepad");
add(b);
b.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
Runtime r=Runtime.getRuntime();
try{
System.out.println(r);
r.exec("notepad");
}
catch(Exception ee){
ee.printStackTrace();
System.out.println("Hi");
}
}
});
}

}

 
Thillai Sakthi
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
Actually why the compiler is throwing a security exception is that you are trying to access the system funtion (in this case it is calculator) from inside an applet. As applets are untrust worthy the compiler is throwing the said exception. If u try to run in a application it works fine.
Hope it clarifies.
MK
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic