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

Comments

Recent Post

Recent Posts Widget

Popular posts from this blog

Capture image from webcam java code, examples

Use of req.query, req.params and req.body in NODE JS

How to capture finger prints in java