File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Difference between Throwable and Exception class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Difference between Throwable and Exception class" Watch "Difference between Throwable and Exception class" New topic

Difference between Throwable and Exception class

balaji sudheer bandi

Joined: Sep 05, 2007
Posts: 1
What is the difference between Throwable and Exception classes.
What is the good procedure to develop user defined exceptions ,by either extending Throwable or Exception class.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17421

This isn't really the right place to ask that question. We have a forum dedicated to Java In General (beginner) questions. When you ask a question in the most appropriate forum, not only are you more likely to get an answer, you'll probably get a better quality answer, since that's where the experts on the subject will be looking. Also, it keeps from cluttering other forums with questions that don't pertain to the forum topic.

But, for a short answer: Throwable is the root of all sequence-interrupting events, including java.lang.Exception. Usually, application developers will want to subclass java.lang.Exception. For more details, I encourage you to ask the folks in the Java In General forum.

An IDE is no substitute for an Intelligent Developer.
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Moving this to the forum suggested by Tim


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15093

Generally, when you create your own exception class, you should either subclass Exception (if you want a checked exception) or RuntimeException (if you want an unchecked exception). Throwable is the superclass for all exceptions and errors and should not be subclassed directly.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Krithika Srinath
Ranch Hand

Joined: Apr 11, 2006
Posts: 52
To add to the previous notes..

It is rarely good practice for a method to catch Throwable. One such scenario could be when you want to log the error message. In general, errors and exceptions should not be masked from the caller.

You can checkthis doc for more details.
I agree. Here's the link:
subject: Difference between Throwable and Exception class
It's not a secret anymore!