?
Solved

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

Posted on 2004-09-09
10
Medium Priority
?
1,618 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 1500 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses
Course of the Month8 days, 18 hours left to enroll

764 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