What is the difference between NoClassDefFoundError and ClassNotFoundException?



NoClassDefFoundError
ClassNotFoundException
It is unchecked exception.
It is checked exception.
If the static provided class is not available at the runtime this error will come.
example like:

MyOwnClass obj=new MyOwnClass ();

if MyOwnClass  is not available at the runtime then NoClassDefFoundError
If the dynamic provided class is not available at the runtime this error will come.
example like:
Object obj=class.forName(“dynamic class”).newInstance();

if dynamic named class is not available then
ClassNotFoundException error will come



Comments