Solved

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

Posted on 2004-09-09
10
1,601 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
The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

 
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

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…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

717 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