What causes and what are the differences between NoClassDefFoundError and ClassNotFoundException?

2021年11月20日 阅读数:2
这篇文章主要向大家介绍What causes and what are the differences between NoClassDefFoundError and ClassNotFoundException?,主要内容包括基础应用、实用技巧、原理机制等方面,希望对大家有所帮助。

问题:

What is the difference between NoClassDefFoundError and ClassNotFoundException ? NoClassDefFoundErrorClassNotFoundException什么区别?java

What causes them to be thrown?是什么致使它们被抛出? How can they be resolved?如何解决?web

I often encounter these throwables when modifying existing code to include new jar files.在修改现有代码以包含新的 jar 文件时,我常常遇到这些 throwable。 I have hit them on both the client side and the server side for a java app distributed through webstart.对于经过 webstart 分发的 java 应用程序,我在客户端和服务器端都遇到了它们。服务器

Possible reasons I have come across:我遇到的可能缘由:app

  1. packages not included in build.xml for the client side of code代码客户端的build.xml未包含的包
  2. runtime classpath missing for the new jars we are using咱们正在使用的新 jar 缺乏运行时类路径
  3. version conflicts with previous jar版本与以前的 jar 冲突

When I encounter these today I take a trail-and-error approach to get things working.当我今天遇到这些时,我会采起跟踪错误的方法来使事情正常进行。 I need more clarity and understanding.我须要更多的清晰度和理解力。ide


解决方案:

参考: https://stackoom.com/en/question/67Fv