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
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
Comments
Post a Comment