NoClassDefFoundError extends LinkageError which in turns extends Error.
Javadoc for Error class states:
An
Error
is a subclass ofThrowable
that indicates serious problems that a reasonable application should not try to catch.
Class loading methods like Class.forName()
only declares ClassNotFoundException
in throws clause. Which, in addition to above description of Error
means that we should not be usually catching the NoClassDefFoundError
when loading classes with Class.forName()
etc.
My question is what are the conditions in which NoClassDefFoundError
is thrown instead of ClassNotFoundException
?