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

ID: Q189167

The information in this article applies to:

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:

   ARTICLE-ID: Q193877
   TITLE     : 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:

   http://www.microsoft.com/java/ 

Additional query words: exit destroy internet explorer kbDSupport
Keywords          : kbcode kbGenInfo kbVJ JSecurity 
Version           : WINDOWS:2.0,2.01,2.02,4.0,4.01
Platform          : WINDOWS
Issue type        : kbinfo

Last Reviewed: November 12, 1998