Difference Between NoClassDefFoundError And ClassNotFoundException

In this tutorial , we will understand the difference between NoClassDefFoundError  and ClassNotFoundException. This is one of the questions to increase the knowledge of java exceptions.
We have already shared the

We will look into the differences , similarities and examples of NoClassDefFoundError and ClassNotFoundException.

Difference between NoClassDefFoundError and ClassNotFoundException

Error vs Exception :  The major difference is in their names. You see that NoClassDefFoundError is Error and derived from LinkageError. It means that NoClassDefFoundError occurs during linking and program can’t run, but compiles successfully.

ClassNotFoundException is Exception and derived from ReflectiveOperationException.
It occurs during runtime
.

Irrecoverable vs recoverable:  NoClassDefFoundError refers irrecoverable situation that are not being handled by try/catch/finally block. ClassNotFoundException is checked exception, which requires handling using try/catch/finally block.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s