Microsoft KB Archive/189167

= INFO: Calling System.exit from Applet Exits Internet Explorer =

Article ID: 189167

Article Last Modified on 11/14/2005

-

APPLIES TO


 * Microsoft Internet Explorer 1.0
 * Microsoft Internet Explorer 2.0
 * Microsoft Internet Explorer 3.0
 * Microsoft Internet Explorer 3.01
 * Microsoft Internet Explorer 3.02
 * Microsoft Internet Explorer 4.0 128-Bit Edition
 * Microsoft Internet Explorer 4.01 128-Bit Edition
 * Microsoft Internet Explorer 5.0
 * Microsoft Internet Explorer 5.01
 * Microsoft Internet Explorer 5.5
 * Microsoft Internet Explorer 3.2
 * Microsoft Internet Explorer 4.0 128-Bit Edition
 * Microsoft Internet Explorer 2.0
 * Microsoft Internet Explorer 3.0
 * Microsoft Internet Explorer 3.01
 * Microsoft Internet Explorer 3.02
 * Microsoft Internet Explorer 4.0 128-Bit Edition
 * Microsoft Internet Explorer 4.01 128-Bit Edition
 * Microsoft Internet Explorer 5.0
 * Microsoft Internet Explorer 5.01
 * Microsoft Internet Explorer 5.5
 * Microsoft Software Development Kit for Java 2.02
 * Microsoft Software Development Kit for Java 2.01
 * Microsoft Software Development Kit for Java 2.02
 * Microsoft Software Development Kit for Java 3.0
 * Microsoft Software Development Kit for Java 3.1

-



This article was previously published under Q189167



SUMMARY
If you have a signed (trusted) applet and your applet calls System.exit, it will cause Internet Explorer to exit.



Steps to Reproduce Behavior
  Save the following to a file named testApp.java: import java.applet.Applet; import java.awt.*; public class testApp extends Applet {        Button b1; public void init {           b1 = new Button("Press"); add("Center", b1); }        public boolean action(Event ev, Object arg) {           if (arg.equals("Press")) {              try {                 System.out.println("Exiting now."); System.exit(0); }              catch (Exception ex) {                 if (ex instanceof SecurityException) System.out.println("Cannot exit browser"); else ex.printStackTrace; }           }            return true; }     }                         Compile the file. You will need to use the tools from the SDK for Java to cab and sign the applet. Run the applet in Internet Explorer 4.0x. Notice that when you click the Press button your browser session will terminate.

NOTE: If you run the applet and it is not cabbed and signed, your browser session will not terminate when you press the button labeled "Press." Rather, you will observe an error message in the javalog, which may be viewed (in Internet Explorer 4.01) by opening the Java Console.

