aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Exception in main Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Exception in main" Watch "Exception in main" New topic
Author

Exception in main

Mauro Mazzucco
Ranch Hand

Joined: Apr 26, 2013
Posts: 32


Why this code compiles fine?
Main is throwing a Exception and noone catchs it, why the compiler doesnt complain?
Ramesh Pramuditha Rathnayake
Ranch Hand

Joined: Oct 31, 2012
Posts: 174
    
    1

It's caught by JVM..


Ramesh-X
Konstantinos Alvertis
Greenhorn

Joined: May 05, 2013
Posts: 11

Your code compiles fine . ( You don't have any syntax error etc ...)

With the

you declare that main method may throw an Exception.


In order to throw the exception add throw new Exception();



As Ramesh said the exception are caught at Runtime by JVM.

OCPJP6
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

Recently discussed in this topic.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1180
A related one at - What does it mean when the main method throws an exception?

Regards,
Dan


William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
M Shareef
Greenhorn

Joined: Jun 10, 2012
Posts: 6

Your code is fine it is printing the "hi" to the console.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception in main