Solved

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

Posted on 2004-09-09
10
1,553 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
  • 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
copyEndy  challenge 15 55
compre toata in where clue oracle 4 41
Java - Why doesn't this JFrame work 3 16
Java DateChooser? 2 5
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now