• Post Reply Bookmark Topic Watch Topic
  • New Topic

NoClassDefFoundError and NoClassDefFoundException  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
What is the difference between NoClassDefFoundException and NoClassDefFoundError. i have found that NoClassDefFoundError occurs when i am using the "new" operator and the class definition is not present while running the program. When does NoClassDefFoundException occur?

Sid
 
Ranch Hand
Posts: 46
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

This input is not sufficiant to conclude give your full code and package directory .Basically this error arise for package mismatching or missing of jars.


Thanks
 
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NoClassDefFoundException ? what is the fully qualified name for it? is it from sun jdk ?
or you meant java.lang.ClassNotFoundException , if yes please search here or google . there are so many discussions.

And Welcome to JavaRanch
 
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is indeed no NoClassDefFoundException. But there is a ClassNotFoundException.

NoClassDefFoundError happens when the JVM cannot load a class that is required, almost always because you forgot to include it in the classpath.

ClassNotFoundException happens when you try to load a class via reflection (for example, when doing Class.forName("...")) and the class cannot be found. Usually this also means that the JAR or directory that contains the class file is missing from the classpath.

Note that the API documentation of NoClassDefFoundError and ClassNotFoundException also explain this, in more detail than I did above.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!