导出jar并导入到eclipse中的项目会导致NoClassDefFoundError异常

发布于 2024-12-15 02:55:04 字数 732 浏览 3 评论 0原文

我自己的项目中有一个第 3 方工作的 JAR 文件,但我遇到了一个问题:我需要进行一些自定义。

  1. 从 Github 分叉一个存储库。
  2. 修改源代码
  3. 导出JAR:左键单击>出口>爪哇> JAR 文件 >默认 设置
  4. 将 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.

  1. Forked a repository from Github.
  2. Modified the source code
  3. Exported the JAR: Left click > Export > Java > JAR file > Default
    settings
  4. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蹲墙角沉默 2024-12-22 02:55:04

是的,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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文