Noclassdeffounderror in Java

In the last article, We have discussed on classnotfoundexception and how to resolve the exception. In this article, we are going to discuss on Noclassdeffounderror in Java.

Noclassdeffounderror in Java occurs when a class was present at compile time but not present at the time of runtime.

The main reason for Noclassdeffounderror  is when the class is having some dependencies on another class and the class changes after compilation of the former class.

Noclassdeffounderror is nothing but linking error. It is very difficult to debug as it is dependent on another class.

Below is some reason for Noclassdeffounderror in Java

  • Class is not present in the classpath.
  • It is a type of linking error. Class is the dependence of another class.
  • You might be running your program using the jar command and the class was not defined in manifest file’s ClassPath attribute.
  • Some jar is dependent on the external jar and those jar are not present in the classpath.

Below is the difference between of Classnotfoundexception and Noclassdeffounderror.

  • Classnotfoundexception occurs when an application tries to load the class at runtime and Noclassdeffounderror occurs class is present at compile time and not present in the runtime.
  • Classnotfoundexception is an exception and it is a type of java.lang.exception and Noclassdeffounderror is an error and type of java.lang error.
  • Classnotfoundexception occurs when classpath is not updated with the required JAR files and Noclassdeffounderror when the class is found during the compile time but not at the run time.


In the last two articles, We have discussed two important exceptions, such as  Classnotfoundexception and Noclassdeffounderror along with reasons for it. Both these exceptions are the related classpath and JVM class loader.

Leave a Reply

Your email address will not be published. Required fields are marked *

Show Buttons
Hide Buttons