Wednesday, October 21, 2009

Difference between NoClassDefFoundError and ClassNotFoundException

"The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found. "

"but no definition for the class with the specified name could be found. "

The explanation given by the javadocs is very misleading.
In reality, NoClassDefFoundError is thrown when the class CAN be found, but there was an exception in the static initializers. The naming strategy chosen by Sun is VERY misleading... one tries to fix the classpath, while the problem is in the class definition itself.

No comments: