Tuesday 17 November 2015

Similarities and Difference b/w ClassNotFoundException and NoClassDefintionFoundException

Similarities :

1) Both NoClassDefFoundError and ClassNotFoundException are related to unavailability of a class at run-time.


2) Both ClassNotFoundException and NoClassDefFoundError are related to java classpath.


Differences :

ClassNotFoundException Thrown when an application tries to load in a class through its name, but no definition for the class with the specified name could be found

NoClassDefFoundError Thrown if the Java Virtual Machine tries to load in the definition of a class and no definition of the class could be found.

ClassNotFoundException is a checked Exception derived directly from java.lang.Exception class and you need to provide explicit handling for it while NoClassDefFoundError is an Error derived from LinkageError.

No comments:

Post a Comment