Friday, 1 August 2014

NoClassDefFoundError

NoClassDefFoundError is a linkage error, thrown when a class 'A' has dependency on other class 'B', latter compilation of class A, class B changed or removed.

Lets take an example

public class B {
    
}

public class A {
    public static void main(String args[]){
        B b = new B();
    }
}

Compile both the files, before running class 'A' remove 'B.class'.

While running the class A, below error thrown.

Exception in thread "main" java.lang.NoClassDefFoundError: B
        at A.main(A.java:3)
Caused by: java.lang.ClassNotFoundException: B
        at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 1 more




                                                             Home

No comments:

Post a Comment