This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Java in General and the fly likes Exception in main method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Exception in main method" Watch "Exception in main method" New topic
Author

Exception in main method

Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1270

What if we throw an exception from catch block of main method.. is it take care by JVM? as it comes at the end in the stack, even after throwing exception from it doesn't require to catch it. statements which are made after throw exception work properly. how jvm do it?


No Kaustubh No Fun, Know Kaustubh Know Fun..
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14117
    
  16

If you throw an exception from the main() method, the JVM will catch it and print a stack trace.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Parvathi Raju
Greenhorn

Joined: Aug 04, 2013
Posts: 9
The main method will terminate if any exception is occur
Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1270

Jesper de Jong wrote:If you throw an exception from the main() method, the JVM will catch it and print a stack trace.


it does because of it is the last in stack to end. why won't jvm handle all exception. what are the reasons that we need to handle checked exception?
 
Consider Paul's rocket mass heater.
 
subject: Exception in main method