aspose file tools*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 1268

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: 13868
    
  10

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: 1268

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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception in main method
 
Similar Threads
main() method throws exception
Another question for NPE.........
Comprehensive Example for Exeption handling
java application using swing
Exception handling and I/o