aspose file tools*
The moose likes Java in General and the fly likes Regarding Exception handling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Regarding Exception handling" Watch "Regarding Exception handling" New topic
Author

Regarding Exception handling

raj talatam
Ranch Hand

Joined: Apr 19, 2012
Posts: 87

who will handle if we throw an exception out of main() by using throws






[Thumbnail for exception.PNG]

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

The JVM will.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
raj talatam
Ranch Hand

Joined: Apr 19, 2012
Posts: 87
Rob Spoor wrote:The JVM will.


how ???
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18745
    
  40

rajendar talatam wrote:
Rob Spoor wrote:The JVM will.


how ???



It's just what it does. The main thread of the JVM is responsible for calling the main() method, and if the method "returns" with an exception condtion, the default uncaught exception handler for the main thread just does a stack trace -- not much handling in my opinion, but handles it regardless.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38394
    
  23
It also terminates the thread the Exception occurred in.
 
Consider Paul's rocket mass heater.
 
subject: Regarding Exception handling