
The difference between ClassNotFoundException and NoClassDefFoundError
--ClassNotFoundException
Thrown when an application tries to load in a class through its string name using
1) Class.forname() method in class Class.
2) ClassLoader.findSystemClass method in class ClassLoader.
3) ClassLoader.loadClass() in class ClassLoader.
As for ClassNotFoundException, it appears that it may stem from trying to make reflective calls to classes at runtime, but the classes the program is trying to call is does not exist.
--NoClassDefFoundError
Thrown if the JVM or a ClassLoader instance tries to load in the definition of a class but no definition could be found.
So, it appears that the NoClassDefFoundError occurs when the source was successfully compiled, but at runtime, the required class files were not found. This may be something that can happen in the distribution or production of JAR files, where not all the required class files were included.
Usually happened when a ref is not found in a class




近期评论