aspose file tools*
The moose likes Beginning Java and the fly likes Uncomprehendable error messages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Uncomprehendable error messages" Watch "Uncomprehendable error messages" New topic
Author

Uncomprehendable error messages

kanaka tam
Ranch Hand

Joined: Jan 19, 2004
Posts: 42
Hello folks,
I would like to thank all the folks who were very helpful in clearing my doubts so far. I couldn't have reached this far without their help. I am a beginner in Java and i am getting uncomprehendable error messages. Funny thing is i am getting the exact output required for this problem but with a dozen error messages while executing. I am not exposed to exception handling but my teacher said that we would be doing it at the last. Here is my code to the problem which has 5 textfields and up and down button and an index field and total field. The user enters the value in the index field and clicks up or down button to increment or decrement the value of the corresponding text field and their total value is displayed.
Here is my code.



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 MyApp.actionPerformed(MyApp.java:124)
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.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
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)

i get all these exceptions and have no idea what it means.
Any help greatly appreciated
Kanaka
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
The more you program in Java the more familiar you will get with error messages like this. This is the typical run-time error you get when an exception is thrown. It's not terribly difficult to understand, either, once you know how. Let me explain.

The first line indicates what exception was thrown and sometimes gives a descriptive message. In this case, an AccessControlException was thrown and the message says "access denied". I think the rest of the message indicates that there was another exception that caused the AccessControlException to be thrown. This probably isn't important at the moment, so you can ignore it.

The rest of the error message follows a distinct pattern. This is what we call the "stack trace". It gives the order of all the methods that were called up to the point where the error occurred. Let's look at the second line in your error message as an example:

at java.security.AccessControlContext.checkPermission(AccessControlContext.java:269)

This tells us that the exception was thrown in the checkPermission() method of the AccessControlContext class in the java.security package. This occurred on line 269 of the file names AccessControlContext.java. Since the AccessControlContext class is from the Java API, there isn't much you can do about the problem at this point. However, note that each line follows the same pattern:

at package.class.method(ClassName.java:line number)

Scan down the list until you find the name of a class that you wrote (e.g. one that isn't in the Java API). The first one I come across says

at MyApp.actionPerformed(MyApp.java:124)

This tells us that your code originally caused the problem on line 124 in the file named MyApp.java. Since I don't have the time to count 124 lines to tell which one this is, I'm just going to make an educated guess. I suspect that the problem is with

System.exit(0);

The problem is that you have written an Applet. Applets are not allowed System.exit() because their life-span is controlled by a separate application (usually a web browser). This is very different from a stand-alone application which has complete control of its own existence. I suspect if you remove this line of code, then you will fix the error message that prompted you to post this question.

I hope this helps.

Layne
[ June 04, 2005: Message edited by: Layne Lund ]

Java API Documentation
The Java Tutorial
kanaka tam
Ranch Hand

Joined: Jan 19, 2004
Posts: 42
Originally posted by Layne Lund:
The more you program in Java the more familiar you will get with error messages like this. This is the typical run-time error you get when an exception is thrown. It's not terribly difficult to understand, either, once you know how. Let me explain.

The first line indicates what exception was thrown and sometimes gives a descriptive message. In this case, an AccessControlException was thrown and the message says "access denied". I think the rest of the message indicates that there was another exception that caused the AccessControlException to be thrown. This probably isn't important at the moment, so you can ignore it.

The rest of the error message follows a distinct pattern. This is what we call the "stack trace". It gives the order of all the methods that were called up to the point where the error occurred. Let's look at the second line in your error message as an example:

at java.security.AccessControlContext.checkPermission(AccessControlContext.java:269)

This tells us that the exception was thrown in the checkPermission() method of the AccessControlContext class in the java.security package. This occurred on line 269 of the file names AccessControlContext.java. Since the AccessControlContext class is from the Java API, there isn't much you can do about the problem at this point. However, note that each line follows the same pattern:

at package.class.method(ClassName.java:line number)

Scan down the list until you find the name of a class that you wrote (e.g. one that isn't in the Java API). The first one I come across says

at MyApp.actionPerformed(MyApp.java:124)

This tells us that your code originally caused the problem on line 124 in the file named MyApp.java. Since I don't have the time to count 124 lines to tell which one this is, I'm just going to make an educated guess. I suspect that the problem is with

System.exit(0);

The problem is that you have written an Applet. Applets are not allowed System.exit() because their life-span is controlled by a separate application (usually a web browser). This is very different from a stand-alone application which has complete control of its own existence. I suspect if you remove this line of code, then you will fix the error message that prompted you to post this question.

I hope this helps.

Layne

[ June 04, 2005: Message edited by: Layne Lund ]


Layne,
Thank you very much. You are a genius. That little line was doing all this. I am elated to see that now my program executes clean. I remember you answering my earlier questions as well. Thanx again.
Kanaka
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
No problem. And I really don't think I'm a genius. I've just encountered similar problems in my journey to master the Java programming language. Experience can go a long way in making you "smarter". Good luck in the rest of your programming endeavors.

Layne
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Uncomprehendable error messages