关闭applet时出现运行时错误

时间:2014-04-09 07:18:30

标签: java applet

我想知道如何阅读这些错误;请任何人帮助我。关闭小程序后显示以下错误

C:\Users\Radha G\Desktop\practice>appletviewer NewApplet.html
Exception in thread "AWT-EventQueue-1" java.security.AccessControlException: acc
ess denied (java.lang.RuntimePermission exitVM)
        at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:264)
        at java.security.AccessController.checkPermission(AccessController.java:
427)
        at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
        at java.lang.SecurityManager.checkExit(SecurityManager.java:744)
        at java.lang.Runtime.exit(Runtime.java:88)
        at java.lang.System.exit(System.java:869)
        at SimpleApplet.actionPerformed(SimpleApplet.java:50)
        at java.awt.Button.processActionEvent(Button.java:388)
        at java.awt.Button.processEvent(Button.java:356)
        at java.awt.Component.dispatchEventImpl(Component.java:3984)
        at java.awt.Component.dispatchEvent(Component.java:3819)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:242)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:163)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)

        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)

        at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

1 个答案:

答案 0 :(得分:1)

从堆栈跟踪中:

    at java.lang.System.exit(System.java:869)  <---- nooo!
    at SimpleApplet.actionPerformed(SimpleApplet.java:50)

您无法从小程序中调用System.exit()

有关如何以正确方式关闭小程序的建议,请参阅How to close java Applet through code