ClassNotFoundException vs NoClassDefFoundError in Java

Advertisements

  Top Tutorials     New Tutorials     Submit     Login     Register  

Tutorial Detail

ClassNotFoundException vs NoClassDefFoundError in Java

From last few weeks I have been facing a cluster of ClassNotFoundException and NoClassDefFoundError while setting up a new project in Java.
http://javarevisited.blogspot.com/2011/07/classnotfoundexception-vs.htmlhttp://javarevisit...
  • Total Hits: 10141

  • Average Rating :
    URL RatingURL RatingURL RatingURL RatingURL Rating

  •  

  • Total Votes: 139 votes

  • Category: JAVA/Core JAVA

  • Submitted on: 2011-08-10 14:53:11

  • Submitted By: Javin Paul

  • Set as Favorite

Description:

Before seeing the differences between ClassNotFoundException and NoClassDefFoundError let's see some similarities which are main reason of confusion between these two errors:

1) Both NoClassDefFoundError and ClassNotFoundException are related to unavaibility of a class at runtime.
2) Both ClassNotFoundException and NoClassDefFoundError are related to java classpath.

Now let's see the difference between NoClassDefFoundError and ClassNotFoundException:

1) ClassNotFoundException comes in java if we try to load a class at runtime using with Class.forName() or ClassLoader.loadClass() or ClassLoader.findSystemClass() method and requested class is not available in Java. the most of the time it looks like that we have the class in classpath    More detail...

Rating Detail

 Stars  Percentage  Total Vote
 One star  Vote LeftVote MiddleVote Right 38.85%  54
 Two starsTwo star  Vote LeftVote MiddleVote Right 10.07%  14
 Three starsThree starsThree stars  Vote LeftVote MiddleVote Right 11.51%  16
 Four starsFour starsFour starsFour stars  Vote LeftVote MiddleVote Right 10.79%  15
 Five starsFive starsFive starsFive starsFive stars  Vote LeftVote MiddleVote Right 28.78%  40

Caste Your Vote

 Rating  Selection  Guidelines
 Poor:     Very disappointing, useless.
 Fair:     Below average, disappointing but not useless.
 Good:     About average in its class.
 Very Good:     Above average for its category.
 Excellent:     One of the best Tutorials in its category.





Advertisements
Advertisements