Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

ClassNotFoundException vs NoClassDefFoundError

DZone's Guide to

ClassNotFoundException vs NoClassDefFoundError

Free Resource

Java-based (JDBC) data connectivity to SaaS, NoSQL, and Big Data. Download Now.

I got a NoClassDefFoundError and I tried to remember the difference between this error and ClassNotFoundException. Unfortunately, I was not able to get the difference so I googled and got the following links:

- http://www.jroller.com/sjivan/entry/difference_between_classnotfoundexception_and_noclassdeffounderror

- http://javafanatics.blogspot.com/2007/03/noclassdeffounderror-vs.html 

  • NoClassDefFoundError is the result of the futile implicit load of the
    class (Class1). Meaning the system classloader is trying to load the
    class Class1 due to inherent call by Class2 (may be an inheritance or
    composition there).
  • ClassNotFoundException comes up when there is an explicit load, using ClassLoader.loadClass, Class.forName etc.

Connect any Java based application to your SaaS data.  Over 100+ Java-based data source connectors.

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}