File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Checked Exception. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Checked Exception." Watch "Checked Exception." New topic
Author

Checked Exception.

Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
When a custom Exception class say "myException" whose super class is
java.lang.Exception is created ,then the compiler considers it as a checked exception. So how can i create a UnChecked Exception ?
Do i need to use this class "RuntimeException".
Super Class of RuntimeException is also "Exception" ? Can any one throw some light on this.


Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
John Dell'Oso
Ranch Hand

Joined: Apr 08, 2004
Posts: 130
For custom unchecked exceptions you must subclass RuntimeException. For checked exceptions you directly subclass Exception.

Regards,
JD
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
But the super class of RuntimeException is also "Exception" ??
John Dell'Oso
Ranch Hand

Joined: Apr 08, 2004
Posts: 130
This is a detail that is handled by the JVM.

The rule is you subclass RuntimeException for unchecked exceptions and subclass Exception for checked exceptions.

Generally speaking, it's always best to use checked exceptions - see this:

Runtime Exceptions - The controversy

Regards,
JD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Checked Exception.