PRB: System.exit() Causes a SecurityExceptionEx

ID: Q179853


The information in this article applies to:
  • Microsoft Win32 Virtual Machine for Java
  • Microsoft Visual J++, versions 1.0, 1.1
    on the following platforms: x86
  • Microsoft Internet Explorer (Programming) versions 3.x, 4.x
    on the following platforms: x86
  • Microsoft SDK for Java, versions 1.5, 1.5.1, 2.0, 2.01, 2.02, 3.0, 3.1


SYMPTOMS

Calling the System.exit() method from a distrusted applet causes a security exception.


CAUSE

An untrusted applet cannot call System.exit() because it causes the browser to shut down.


RESOLUTION

If your program needs to call System.exit(), you must make the applet trusted.


STATUS

This behavior is by design.


MORE INFORMATION

The sample code below generates the following security exception:


   com.ms.security.SecurityExceptionEx[SystemExit.action] 

Sample Code


import java.awt.*;

public class SystemExit extends java.applet.Applet
{
  public void init()
  {
     add(new Button("Exit"),"Center");
  }
  public boolean action(Event e, Object o)
  {
     System.exit(0);
     return true;
  }
} 


REFERENCES

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

Q193877 HOWTO: Make your Java Code Trusted in Internet Explorer
For more information on making your applet trusted, please see the Microsoft SDK for Java 2.0x documentation, available at http://www.microsoft.com/java/sdk/.

For the latest Knowledge Base articles and other support information on Visual J++ and the SDK for Java, see the following pages on the Microsoft Technical Support site:
http://support.microsoft.com/support/visualj/

http://support.microsoft.com/support/java/

Additional query words: system exit trusted applet

Keywords : kbIE300 kbIE400 kbSDKJava150 kbSDKJava151 kbSDKJava200 kbSDKJava201 kbSDKJava300 kbVJ100 kbVJ110 kbSDKJava202
Version : :; WINDOWS:1.0,1.1,1.5,1.5.1,2.0,2.01,2.02,3.0,3.1,3.x,4.x
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: January 3, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.