java. langNoClassdefFoundError & java. lang.ClassNotFoundException

Today, my little friend encountered a problem,

The exception information is as follows:

java.lang.NoClassDefFoundError:Could not initialize class XXX

The NoClassDefFoundError exception class is related to the classnotfoundexception exception class. It feels very similar. What's the difference?

NoClassdefFoundError(unchecked exception/runtime exception):

The class loader view loads the class definition, but the class definition cannot be found. In fact, the class file exists;

ClassNotFoundException(checked exception):

The root cause of this exception class is that the class file cannot be found.

When you encounter one of these two in the future, you can grasp the general situation of mistakes.

The following connection explains the checked & unchecked exceptions:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>