Runtime Exec Applet runs with Appletviewer but not with IE or Netscape
843798Jul 11 2001 — edited Jul 12 2001I have created an applet that open the notepad when a button is clicked. (It is the previous applet that will open a software design application that we want to control and administrate over our corporate network). This is the code:
import java.awt.*;
import java.applet.Applet;
import java.io.*;
public class botex extends Applet {
Button b1;
public void init() {
b1 = new Button( "Boton B1" );
this.add( b1 );
}
public boolean action( Event evt,Object obj ) {
if( evt.target.equals( b1 ) )
try{
Runtime.getRuntime().exec("notepad.exe");
} catch (IOException exception) {
System.out.println ( "we cant open notepad");
}
return true;
}
}
I have compiled it with JDK 1.1.4 java compiler.
Then I have embedded the botex.class file into the botex.htm with the following sintax:
<HTML>
<HEAD>
<TITLE>
</TITLE>
</HEAD>
<BODY>
<APPLET CODE="botex.class" WIDTH="150" HEIGHT="100"></APPLET>
</BODY>
</HTML>
So when the applet is run from the DOS command line :
c:> appletviewer botex.htm
The applet is started and when you click the button it opens the notepad.
BUT WHEN YOU OPEN THE botex.htm with any of the famous browsers IE (5.50) or Netscape (4.75) you can see the button, but when you click, nothing happens, not even the catch exception message appear.
Anyone can tell me how to make this applet work with the browser???
I really appreciate your help