Solved

Problem with Exception "java.security.AccessControlException: access denied (java.lang.RuntimePermission exitVM)"

Posted on 2004-09-09
10
1,582 Views
Last Modified: 2011-01-11
Hi,
I am trying to run an applet program using netbeans IDE3.6 .
In my Program i created a menu name File >Exit .

In ActionListener of exit i am using system.exit(0) when i click i am getting the below exception.



java.security.AccessControlException: access denied (java.lang.RuntimePermission exitVM)
        at java.security.AccessControlContext.checkPermission(AccessControlContext.java:269)
        at java.security.AccessController.checkPermission(AccessController.java:401)
        at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
        at java.lang.SecurityManager.checkExit(SecurityManager.java:736)
        at java.lang.Runtime.exit(Runtime.java:88)
        at java.lang.System.exit(System.java:715)
        at pro.framestrucu.actionPerformed(framestrucu.java:77)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
        at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
        at javax.swing.AbstractButton.doClick(AbstractButton.java:289)
        at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1113)
        at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseReleased(BasicMenuItemUI.java:943)
        at java.awt.Component.processMouseEvent(Component.java:5100)
        at java.awt.Component.processEvent(Component.java:4897)
        at java.awt.Container.processEvent(Container.java:1569)
        at java.awt.Component.dispatchEventImpl(Component.java:3615)
        at java.awt.Container.dispatchEventImpl(Container.java:1627)
        at java.awt.Component.dispatchEvent(Component.java:3477)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
        at java.awt.Container.dispatchEventImpl(Container.java:1613)
        at java.awt.Component.dispatchEvent(Component.java:3477)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)



any ideas are welcome.
0
Comment
Question by:vihar123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
10 Comments
 
LVL 92

Expert Comment

by:objects
ID: 12022007
You cannot use System.exit() in an applet.
0
 
LVL 92

Expert Comment

by:objects
ID: 12022009
Try instead loading a different page using showDocument.
0
 
LVL 35

Expert Comment

by:girionis
ID: 12024088
Open up your java policy file and grant the following permission:

permission java.lang.RuntimePermission "exitVM";

inside the grant
{
...
...
}

block of code. Tell us if it helps, if it does you will need to sign your applet in order to use it on other computers that you do not have access.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 92

Expert Comment

by:objects
ID: 12024122
you cannot exit the applet's vm with System.exit().

If you want to close the window then try calling js from your applet using:

netsape.javascript.JSObject window = netscape.javascript.JSObject.getWindow(applet);
window.call("closeWindow", null);

or load a new page using showDocument() that has some onLoad javascript to close the window.
0
 
LVL 35

Expert Comment

by:girionis
ID: 12024179
I thought it might worth a try.

vihar123, you might as well call destroy() manually.
0
 
LVL 35

Expert Comment

by:girionis
ID: 12024231
>  you cannot exit the applet's vm with System.exit().

So the actual problem is that you cannot exit the applet, not that you cannot call System.exit(0);
0
 
LVL 92

Expert Comment

by:objects
ID: 12024251
you can exit an applet by simply unloading the page.
0
 

Author Comment

by:vihar123
ID: 12024733
Hi,
i tried calling destroy maually also but no response.
how to unload the page? :)
0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 12024745
> how to unload the page? :)

getAppletContext().showDocument("anotherpage.html");

0
 
LVL 92

Expert Comment

by:objects
ID: 12060463
:)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question