Difference between NoClassDefFoundError and ClassNotFoundException

绝地灬酷狼 2022-07-13 16:27 331阅读 0赞
  1. 1)
  2. public class ClassNotFoundExceptionextends Exception
  3. Thrown when an application tries to load in a class through its string name using:
  4. \* The forName method in class Class.
  5. \* The findSystemClass method in class ClassLoader .
  6. \* The loadClass method in class ClassLoader.
  7. but no definition for the class with the specified name could be found.
  8. As of release 1.4, this exception has been retrofitted to conform to the general purpose exception-chaining mechanism.
  9. The "optional exception that was raised while loading the class" that may be provided at construction time and accessed
  10. via the getException() method is now known as the cause,
  11. and may be accessed via the Throwable.getCause() method, as well as the aforementioned "legacy method."
  12. 2)
  13. public class NoClassDefFoundErrorextends LinkageError
  14. Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class
  15. (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found.
  16. The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found.

发表评论

表情:
评论列表 (有 0 条评论,331人围观)

还没有评论,来说两句吧...

相关阅读