NoClassDefFoundError
An error thrown when a class that was present at compile time cannot be found at run time.
In more detail
It usually means the run-time class path differs from the compile-time one, for example java -jar ignoring -cp. It is an Error, not an Exception. The message names the missing class with slashes.
Example
Exception in thread "main" java.lang.NoClassDefFoundError: com/acme/text/ShoutRelated terms
- class path — The list of folders and JAR files the JVM and the compiler search to find classes.
- JAR manifest — The text file inside a JAR, stored in its META-INF folder, that records metadata such as the main class to run.
Taught in
- Jars, Automatic Modules And Runtime Images — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep