Microsoft KB Archive/179853

= PRB: System.exit Causes a SecurityExceptionEx =

Article ID: 179853

Article Last Modified on 11/14/2005

-

APPLIES TO


 * Microsoft Java Virtual Machine
 * Microsoft Visual J++ 1.0 Standard Edition, when used with:
 * the hardware: Intel x86
 * Microsoft Visual J++ 1.1 Standard Edition, when used with:
 * the hardware: Intel x86
 * Microsoft Internet Explorer 3.0, when used with:
 * the hardware: Intel x86
 * Microsoft Internet Explorer 3.01, when used with:
 * the hardware: Intel x86
 * Microsoft Internet Explorer 3.02, when used with:
 * the hardware: Intel x86
 * Microsoft Software Development Kit for Java 1.5
 * Microsoft Software Development Kit for Java 1.51
 * 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 Q179853



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; } }

