jQuery in Action, 3rd edition
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
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: 90

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: 20080
    
  30

The JVM will.


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

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


how ???
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 20057
    
  44

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: 44006
    
  33
It also terminates the thread the Exception occurred in.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding Exception handling
 
It's not a secret anymore!