Thursday, July 22, 2010

classNotFoundException vs NoClassDefFoundError

classNotFoundException
1-Thrown when an application tries to load in a class through its string name using -
1-The forName method in class Class
2-The findSystemclass method in class ClassLoader
3-The loadClass method in class ClassLoader
2-ClassNotFoundException indicates that a class needed for compilation cannot be found on the classpath
3-This is Compiler Time Exception.
4-ClassNotFoundException Extending the Exception Class
5-ClassNotFoundException is a checked exception.
6-Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found.

NoClassDefFoundError

1-NoClassDefFoundError indicates that the matching class that was found at compile time cannot be found at runtime.
2-NoClassDefFoundError is error not the exception.
3-This run time Error .
4-The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found.