File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes About  Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "About  Error" Watch "About  Error" New topic
Author

About Error

YingShiuan Chang
Greenhorn

Joined: Feb 18, 2004
Posts: 6
An Error indicates serious problems that a reasonable application should not try to catch. When an error is produced, does the program break off or continue running? Or it depends on what kinds of errors?
For instance, when OutOfMemoryError is produced, what will it happen?
Thanks.
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
An Error gets thrown like an Exception and can be caught like one. If the Error is not caught, the code that called your main method gets control and causes a stack trace to be printed. This will show you the type of Error, where it happened, and how you got there from your main method.
You can also catch an Error and try to handle it. For instance, you might designate some objects for garbage collection by setting their references to null. However, you should then do as little as possible (write critical data, release locked database records) and rethrow the error. This will give you the stack trace and allow the operator to cleanly restart the application. Remember that your execution environment may be corrupted as a result of the Error in a way you can't repair.


Mike Gershman
SCJP 1.4, SCWCD in process
YingShiuan Chang
Greenhorn

Joined: Feb 18, 2004
Posts: 6
Thank you for your help.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: About Error
 
Similar Threads
Problem in saving jsp file
Passing a variable from one class to another
while after while
Error Message
Does not compile vs Compiles with Error? (John Hunt Mock Exam)