Difference between Classnotfoundexception and Noclassdeffounderror

Main Difference

ClassNotFoundException is a checked Exception, It’s tossed when that required class is not present in the area where classloader is looking. NoClassDefFoundError is a blunder. It’s tossed to demonstrate that ClassLoader occasion is attempting to stack in the meaning of a class and no meaning of the class is found. The looked for class definition existed when the as of now executing class was incorporated, yet the definition can never again be found. The contrast between the two is that one is an Error and the other is an Exception. NoClassDefFoundError, on the other side, is an Error and it emerges from actuality the Java Virtual Machine having issues finding a class it anticipated that would discover. A project that was relied upon to work at the incorporate time can’t run as a result of class records not being found, or is not the same as was created or experienced at order time. This is a basic blunder, as the system can’t be started by the JVM. In contrast, the ClassNotFoundException is an Exception, which is normal, and recoverable. A blunder may happen amid class stacking, then a case of a subclass of LinkageError must be tossed at a point in the project that (specifically or in a roundabout way) utilizes the class or interface being stacked. The significant contrast is in their names. You see that NoClassDefFoundError is Error and got from LinkageError. It implies that NoClassDefFoundError happens amid connecting and the program can’t run, however, gathers effectively. ClassNotFoundException is Exception and got from ReflectiveOperationException. It happens amid runtime. NoClassDefFoundError alludes irretrievable circumstance that is not being taken care of by attempt/get/at last square. ClassNotFoundException is checked special case, which requires taking care of utilizing attempt/get/at long last piece. The Java Virtual Machine ever endeavors to stack a class C amid confirmation (§5.4.1) or determination (§5.4.3) (yet not introduction (§5.5)), and the class loader that is utilized to start stacking of C tosses an occasion of ClassNotFoundException, then the Java Virtual Machine has to be tossed a case of NoClassDefFoundError whose cause is the example of ClassNotFoundException. Numerous a time we mistook ourselves for java.lang.ClassNotFoundException and java.lang.NoClassDefFoundError, however them two identified with Java Classpath they are totally diverse to each other. ClassNotFoundException comes when JVM tries to the heap a class at runtime progressively implies you give the name of the class at runtime and after that JVM tries to load it and if that class is not found in the classpath it tosses java.lang.ClassNotFoundException. While on account of NoClassDefFoundError the tricky class was available amid Compile time and that is the reason the system effectively incorporated however not accessible amid runtime by any reason. NoClassDefFoundError is simpler to settle than ClassNotFoundException as I would see it on the grounds that here we realize that Class was available amid assemble time, yet it thoroughly relies on environment when you are working in the J2EE environment then you can get NoClassDefFoundError regardless of the fact that the class is available on the grounds that it may not be unmistakable to the comparing class loader.


The nature of the ClassNotFoundException is run time exemption which is tossed when an application tries to stack a class at runtime utilizing Class.forName () or loadClass () or findSystemClass () strategies and the class with indicated name are not found in the classpath. For instance, you may have gone over this special case when you attempt to interface with MySQL or Oracle databases and you have not redesigned the classpath with required JAR documents. In the greater part of time, this special case happens when you attempt to run an application without overhauling the classpath with required JAR records. It happens when an application tries to stack a class at a run time which is not overhauled in the classpath. It is tossed by the application itself. It is tossed by the techniques like Class.forName (), loadClass () and findSystemClass ().


NoClassDefFoundError is a blunder which is tossed when Java Runtime System tries to stack the meaning of a class and class definition is no more accessible. The required class definition was available at an aggregate time yet it was absent at the run time. For instance, aggregate the underneath system. It is a blunder. It is of sort java.lang.Error. It happens when java runtime framework doesn’t discover a class definition, which is available at the aggregate time, however missing at run time. NoClassDefFoundError in Java comes when Java Virtual Machine is not ready to locate a specific class at runtime which was accessible amid arrange a time. For instance, on the off chance that we have a strategy call from a class or getting to any static individual from a Class and that class is not accessible amid run-time then JVM will toss NoClassDefFoundError. Numerous Java engineer blends this two Error and gets confounded. In short NoClassDefFoundError will come if a class was available amid arrange time yet not accessible in java classpath amid runtime. Typically you will see beneath line in the log when you get NoClassDefFoundError. A special case in string “fundamental” basically demonstrate that it’s “principle” string which is not ready to locate a specific class it could be any string so simply don’t stress. You are truly inquisitive and imagine that you see how class stacking functions, I recommend you attempt some riddles from Joshua Bloch’s Java Puzzlers, it has got some truly precarious inquiries to test your insight.

Key Differences

  • Both of them are quite different terms as the error is the Noclassdeffounderror while the other one is an exception.
  • When the classpath is not modernized according to the requirements of the JAR files, then ClassNotFoundException will happen. Quite the opposite, when the compulsory class definition is not present at the run time, then the Noclassdeffounderror come into existence.

Video Explanation

Leave a Comment

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