Solved

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

Posted on 2004-09-09
10
1,561 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

920 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

16 Experts available now in Live!

Get 1:1 Help Now