7/15/2013

Difference between In ClassNotFoundException & NoClassDefFoundError ?

Difference between In ClassNotFoundException & NoClassDefFoundError ?

ClassNotFoundException:

java.lang.Object
     java.lang.Throwable.
            java.lang.Exception.
                   java.lang.ClassNotFoundException

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.
but no definition for the class with the specified name could be found.


NoClassDefFoundError:

java.lang.Object
  java.lang.Throwable
      java.lang.Error
          java.lang.LinkageError
              java.lang.NoClassDefFoundError

Search for the class definition after compiled successfully of class, but definition can no longer found.
Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class.

*Please correct me if wrong or additional Info.

1 comment: