Login with  Log in with facebook
Hiring Manager? SIGN UP HERE
0

what is the difference between the two. To me both looks same.

Eric Smith
09/08/2011 at 09:14
1 Answer
1
0

NoClassDefFoundError is thrown when the class definition cannot be found by the class loader during runtime. Usually this means a linkage error. A ClassNotFoundException though is thrown when you try to load a class through reflection and this is not found. The actual difference between the two is just for a way for JVM to tell you that in one case, the program was successfully compiled but at runtime it cannot find anymore one or more of your classes and in the other case that it just cannot find your classes at all (which may have been not needed at all during compile time, aka reflection).

The NoClassDefFoundError message tells you that there is a hard reference in your program to a class, which was compiled successfully but it cannot be found anymore while the program runs and the ClassNotFoundException tells you that you want to load a class and the classloader cannot find it at all. This class may be a class from a 3-rd party library that your program somehow wants to load (usually through reflection).

Georgios Gkekas
09/09/2011 at 09:01

If you want to post any answer to this forum then you need to log in.
Schedule a Demo

Schedule a Demo with us

Name *
Email *
Phone *
Company *
Details