Difference NoClassDefFoundException and ClassNotFoundException

NoClassDefFoundException occurs when class is loaded as statically and ClassNotFoundException occurs when class is loaded as dynamically.

Static class loading:-

Car c = new TestClass();

Dynamically class loading:-
Class.forName(“TestClass”);


According to arun:-

Consider, you have two custom classloaders - CL1 and CL2. A class loaded by CL1 when tried to be accessed by CL2 will also throw a ClassNotFoundException.

And consider you have Class1 loaded by both CL1 and CL2, they both are not compatible even through they are the same. There we give some job to ClassCastException.

Thanks
Arun
www.arunma.com

Popular posts from this blog

What is NBioBSP Java Library?

Draw arrow line example

Capture image from webcam java code, examples