Eclipse Ivyde托管库未导出到可运行的jar文件中

发布于 2025-02-05 08:18:28 字数 2622 浏览 3 评论 0原文

到目前为止

,Eclipse将Ivyde托管库导出到可运行的JAR文件中,但我不确定为什么它最近停止工作。

怎么了?如何解决这个问题?

ivy.xml

<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation= "http://ant.apache.org/ivy/schemas/ivy.xsd">
  <info organisation="com.example" module="eclipse-ivyde-export-issue" />
  <dependencies>
    <dependency org="org.json" name="json" rev="20220320"/>
  </dependencies>
</ivy-module>

复制问题的步骤

  1. clone

      git克隆 [emagy&nbsp; emagy&nbsp; -ivyde-export-issue.git
     
  2. 将克隆的项目导入eclipse workspace。

    /p>

  3. 右键单击类src/com..example/main.java在项目树和 选择运行为→Java应用程序。请参阅输出:{“ key”:“ value”}

  4. 右键单击项目并选择导出→Java→可运行的JAR文件。

  5. 选择类的启动配置com.example.main和 库处理:[x]提取物需要库中生成的jar。点击 完成。

  6. 尝试运行生成的JAR文件:

      $ java -jar eclipse-ivyde-export-issue.jar
    线程“ main” java.lang.noclassdeffounderror中的例外:org/json/jsonobject
      在com.example.main.main(main.java:8)
    引起:java.lang.classnotfoundexception:org.json.jsonobject
      at Java.base/jdk.internal.loader.builtinclassloader.loadclass(buildinclassloader.java:641)
      at Java.base/jdk.internal.loader.classloaders $ appclassloader.loadclass(classloaders.java:188)
      at Java.base/java.lang.classloader.loadclass(classloader.java:520)
      ...另外
     

环境

  • Eclipse 2022-06 m2(
  • m2
  • 4.24.0
  • 尝试运行生成的

) -06使用OpenJDK 8工作正常,

我用Eclipse 2020-06和OpenJDK 8测试了同一项目。JAR Export发出警告“此操作重新包装引用的库”,IVYDE托管类都包含在生成的JAR文件中。

(这个问题也发布到 eclipse社区论坛

The problem

So far, Eclipse has exported IvyDE managed libraries into a runnable JAR file, but I'm not sure why it has stopped working recently.

What's wrong? How can I fix the issue?

ivy.xml

<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation= "http://ant.apache.org/ivy/schemas/ivy.xsd">
  <info organisation="com.example" module="eclipse-ivyde-export-issue" />
  <dependencies>
    <dependency org="org.json" name="json" rev="20220320"/>
  </dependencies>
</ivy-module>

Steps for reproducing the issue

  1. Clone the project:

    git clone [email protected]:haba713/eclipse-ivyde-export-issue.git
    
  2. Import the cloned project into Eclipse workspace.

  3. Right-click the class src/com.example/Main.java in the project tree and
    choose Run as → Java Application. See the output: {"key":"value"}.

  4. Right-click the project and choose Export → Java → Runnable JAR file.

  5. Choose the launch configuration for the class com.example.Main and
    Library handling: [x] Extract required libraries into generated JAR. Click
    Finish.

  6. Try to run the generated JAR file:

    $ java -jar eclipse-ivyde-export-issue.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONObject
      at com.example.Main.main(Main.java:8)
    Caused by: java.lang.ClassNotFoundException: org.json.JSONObject
      at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
      at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
      at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
      ... 1 more
    

Environment

  • Eclipse 2022-06 M2 (4.24.0 M2)
  • IvyDE 2.2.0.final-201311091524-RELEASE
  • OpenJDK 17.0.3+7-Debian-1deb11u1
  • Debian GNU/Linux 11 (Bullseye)

Eclipse 2020-06 with OpenJDK 8 works fine

I tested the same project with Eclipse 2020-06 and OpenJDK 8. JAR export gives a warning "This operation repacks referenced libraries" and IvyDE managed classes are included into the generated JAR file.

(The question was posted also to Eclipse Community Forums.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

夜清冷一曲。 2025-02-12 08:18:28

解决方法

我认为这是JDT或IVYDE错误。解决方法是使用JRE系统库1.8而不是17。请参见读书结束时的注释以获取更多信息。

所选的启动配置必须具有JDK 1.8作为运行时环境。

Workaround

I think that this is a JDT or IvyDE bug. Workaround is to use JRE System Library 1.8 instead of 17. See the note at the end of README for more information.

The chosen Launch configuration must have JDK 1.8 as a runtime environment.

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