NoClassDefFoundError in Java — What It Means and How to Fix It
What Java's NoClassDefFoundError means and how to fix it.
Published November 3, 2026
NoClassDefFoundError means a class was present at compile time but could not be found (or failed to initialise) at runtime.
What it means and why it happens
Typical causes: missing jars in deployment, a static initializer that failed earlier, or conflicting versions.
Read the full message: it names the file and line where the problem was detected, which is the best place to start.
What you see
run the code
java.lang.NoClassDefFoundError: com/example/Helper
Practical examples
Code that triggers it
new Helper().run(); // Helper.class missing at runtimeThe fix
// ensure the class/jar is packaged
// mvn clean package
// check static initializers for exceptionsLook for the first failure
Search the logs for ExceptionInInitializerError, the real cause.Common mistakes
- Deploying a thin jar without dependencies.
- Static init exceptions hidden earlier in logs.
- Different library versions in the classpath.
Key takeaways
- NoClassDefFoundError: NoClassDefFoundError means a class was present at compile time but could not be found (or failed to initialise) at runtime.
- Read the message and the line number first.
- Fix the cause, don't just silence the error.
FAQ
Why only at runtime?
Compilation used the class; the runtime environment lacks it.
How do I find which line caused NoClassDefFoundError?
The error message and stack trace show the file and line; start there and work backwards.