INFO: Calling System.exit() from Applet Exits Internet Explorer (189167)



The information in this article applies to:

  • Microsoft Internet Explorer 1.0 for Windows 95
  • Microsoft Internet Explorer 2.0 for Windows 95
  • Microsoft Internet Explorer 3.0 for Windows 95
  • Microsoft Internet Explorer 3.01 for Windows 95
  • Microsoft Internet Explorer 3.02 for Windows 95
  • Microsoft Internet Explorer 4.0 for Windows 95
  • Microsoft Internet Explorer 4.01 for Windows 95
  • Microsoft Internet Explorer 5.0 for Windows 95
  • Microsoft Internet Explorer 5.01 for Windows 95
  • Microsoft Internet Explorer 5.5 for Windows 95
  • Microsoft Internet Explorer 3.x for Windows 95
  • Microsoft Internet Explorer 4.x for Windows 95
  • Microsoft Internet Explorer 2.0 for Windows NT 4.0
  • Microsoft Internet Explorer 3.0 for Windows NT 4.0
  • Microsoft Internet Explorer 3.01 for Windows NT 4.0
  • Microsoft Internet Explorer 3.02 for Windows NT 4.0
  • Microsoft Internet Explorer 4.0 for Windows NT 4.0
  • Microsoft Internet Explorer 4.01 for Windows NT 4.0
  • Microsoft Internet Explorer 5.0 for Windows NT 4.0
  • Microsoft Internet Explorer 5.01 for Windows NT 4.0
  • Microsoft Internet Explorer 5.5 for Windows NT 4.0
  • Microsoft SDK for Java 2.0
  • Microsoft SDK for Java 2.01
  • Microsoft SDK for Java 2.02
  • Microsoft SDK for Java 3.0
  • Microsoft SDK 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.

MORE INFORMATION

Steps to Reproduce Behavior

  1. 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;
             }
          }
    						
  2. Compile the file.
  3. You will need to use the tools from the SDK for Java to cab and sign the applet.
  4. Run the applet in Internet Explorer 4.0x.
  5. 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.

REFERENCES

For additional information on making your Java Code trusted in Microsoft Internet Explorer, please refer to the following Knowledge Base article:

193877 HOWTO: Make your Java Code Trusted in Internet Explorer

For more information on Cabbing and Signing a Java Applet, please refer to the SDK for Java documentation at the following Web site:

Modification Type:MinorLast Reviewed:11/14/2005
Keywords:kbArtTypeINF kbcode kbinfo KB189167