ClassNotFoundException Vs NoClassDefFoundError in Java Last Updated : 17 Nov, 2025 Comments Improve Suggest changes 22 Likes Like Report ClassNotFoundException and NoClassDefFoundError both indicate class loading failure they occur in different scenarios and have different root causes. ClassNotFoundException occurs when a class is missing at runtime while loading it dynamically through mechanisms like Class.forName. while NoClassDefFoundError appears when the class was available during compilation but cannot be found or loaded at runtime.What Is ClassNotFoundException?ClassNotFoundException is a checked exception thrown when a class is requested at runtime but the JVM cannot locate it in the classpath.Occurs when a class is loaded dynamicallyHappens during runtimeUsually caused by missing or incorrect classpath entriesThrown by Class.forName(), ClassLoader.loadClass() and reflection-based operations Java public class Demo { public static void main(String[] args) { try { Class.forName("com.example.MissingClass"); } catch (ClassNotFoundException e) { System.out.println("Class not found"); } } } This exception appears when the class com.example.MissingClass is not present in the runtime classpath.What Is NoClassDefFoundError?NoClassDefFoundError is an error thrown by the JVM when it tries to load a class that was available during compilation but is missing at runtime.Occurs when a class was compiled successfully but cannot be found laterHappens during class loading by the JVMIndicates missing JAR files or removed classes after compilationRaised as an error not as an exception Java public class Main { public static void main(String[] args) { Helper.help(); } } class Helper { static void help() { System.out.println("Running"); } } If the Helper class gets deleted from the classpath after compilation the JVM throws NoClassDefFoundError when executing the program.Comparison Table: ClassNotFoundException Vs NoClassDefFoundErrorAspectClassNotFoundExceptionNoClassDefFoundErrorTypeChecked exceptionErrorThrown ByApplication codeJVMWhen It OccursRuntime while loading a class dynamicallyRuntime when a previously available class is now missingTypical CauseWrong or missing classpath for dynamic loadingMissing JAR or class removed after compilationCommon ScenariosJDBC drivers reflection frameworksDeployment issues, incorrect builds missing dependencies Create Quiz Comment N NishuAggarwal Follow 22 Improve N NishuAggarwal Follow 22 Improve Article Tags : Java Difference Between Java-Exceptions Explore Java BasicsIntroduction to Java3 min readJava Programming Basics9 min readJava Methods6 min readAccess Modifiers in Java4 min readArrays in Java7 min readJava Strings7 min readRegular Expressions in Java3 min readOOP & InterfacesClasses and Objects in Java5 min readAccess Modifiers in Java4 min readJava Constructors4 min readJava OOP(Object Oriented Programming) Concepts10 min readJava Packages2 min readJava Interface7 min readCollectionsCollections in Java12 min readCollections Class in Java13 min readCollection Interface in Java4 min readIterator in Java4 min readJava Comparator Interface5 min readException HandlingJava Exception Handling6 min readJava Try Catch Block4 min readJava final, finally and finalize4 min readChained Exceptions in Java3 min readNull Pointer Exception in Java5 min readException Handling with Method Overriding in Java4 min readJava AdvancedJava Multithreading Tutorial3 min readSynchronization in Java7 min readFile Handling in Java4 min readJava Method References9 min readJava 8 Stream Tutorial7 min readJava Networking6 min readJDBC Tutorial5 min readJava Memory Management3 min readGarbage Collection in Java6 min readMemory Leaks in Java3 min readPractice JavaJava Interview Questions and Answers15+ min readJava Programs - Java Programming Examples7 min readJava Exercises - Basic to Advanced Java Practice Programs with Solutions5 min readJava Quiz1 min readJava Project Ideas For Beginners and Advanced15+ min read Like