导出jar并导入到eclipse中的项目会导致NoClassDefFoundError异常
我自己的项目中有一个第 3 方工作的 JAR 文件,但我遇到了一个问题:我需要进行一些自定义。
- 从 Github 分叉一个存储库。
- 修改源代码
- 导出JAR:左键单击>出口>爪哇> JAR 文件 >默认 设置
- 将 JAR 导入到我自己的 Android 项目中:左键单击 > 导入>文件系统与左键单击项目>属性>爪哇 构建路径>添加 JAR >好的
,现在,当我运行我的程序(与第 3 方官方 JAR 一起正常工作)时,我在运行时遇到异常:
11-10 06:22:05.912: E/AndroidRuntime(1125): Caused by: java.lang.NoClassDefFoundError: org.jsoup.Jsoup
当我提取 JAR 文件时,它包含所有需要的类文件(包括 org.jsoup.Jsoup)。
NoClassDefFoundError - 读取类定义时出错。当相关类具有使用类加载器未找到的类的静态块或成员时,通常会发生这种情况。 来源
据我了解,这似乎是某种导出的 JAR 类路径问题?
Had a 3rd parties working JAR file in my own project, but I ran into a problem: i needed some customization to do.
- Forked a repository from Github.
- Modified the source code
- Exported the JAR: Left click > Export > Java > JAR file > Default
settings - Imported the JAR to my own Android project: Left click >
Import > File system & Left Click on project > Properties > Java
Build Path > Add JARs > OK
Now, when I run my program (which was working fine with 3rd parties official JAR) I run into exception on runtime:
11-10 06:22:05.912: E/AndroidRuntime(1125): Caused by: java.lang.NoClassDefFoundError: org.jsoup.Jsoup
When I extract the JAR file, then it contains all the needed class files (including org.jsoup.Jsoup).
NoClassDefFoundError - error reading the class definition. This typically happens when the class in question has static blocks or members which use a Class that's not found by the ClassLoader. Source
As I understand, this seems to be some kind of exported JAR classpath problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,NoClassDefFoundError通常意味着类路径问题,尤其是有很多类加载器。但我认为你的情况很简单。
您确定是“Java Build Path > Add JARs”吗?
在我的记忆中,这是一个“Java Build Path > Add external JARs”选项。也许你可以尝试一下。
Yeah , NoClassDefFoundError usually means the classpath problem , especially there are many class loaders. But I think yours is a simple case.
Are you sure it's " Java Build Path > Add JARs"?
It's a " Java Build Path > Add External JARs" option in my memory .Maybe you can try.