ClassNotFoundException and NoClassDefFoundError both signal a missing class, but they differ in cause and timing. ClassNotFoundException is a checked exception thrown when code explicitly tries to load a class by name, such as with Class.forName(), and the classpath doesn't contain it, while NoClassDefFoundError is an unchecked error thrown when a class that was available at compile time can no longer be found or failed to initialize at runtime.
Deploying a jar without one of its dependency jars on the classpath causes NoClassDefFoundError at runtime for a class the code compiled against successfully, whereas calling Class.forName with a typo in the class name throws ClassNotFoundException immediately.
A concise interview answer is
ClassNotFoundException is a checked exception thrown when you explicitly try to load a class by name, like with Class.forName, and it isn't on the classpath. NoClassDefFoundError is an unchecked error thrown when a class that compiled fine can't be found or failed to initialize at runtime, often due to a classpath mismatch or a static initializer that threw an exception earlier.
Last updated: 16 July 2026
Previous question: How does the static keyword affect memory management in Java?
Next question: How does class loading affect memory usage?