Class Exception
What is difference between ClassNotFoundException and NoClassDefFoundError?
1. ClassNotFoundException is an exception and NoClassDefFoundError is an error.
2. ClassNotFoundException occurs when an application tries to load a class using it name via one of the followings and no class with the name is found.
The forName method in class Class
The findSystemClass method in class ClassLoader.
The loadClass method in class ClassLoader
NoClassDefFoundError is thrown when Class Loader tries to load a class definition statically using "new".
3. NoClassDefFoundError error occur when the source was compiled successfully but class is not available at runtime.
References:
1. Understanding the ClassLoader by Greg Travis (2001)