Eclipse Ivyde托管库未导出到可运行的jar文件中
到目前为止
,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>
复制问题的步骤
git克隆
[emagy&nbsp; emagy&nbsp; -ivyde-export-issue.git
将克隆的项目导入eclipse workspace。
/p>
右键单击类
src/com..example/main.java
在项目树和 选择运行为→Java应用程序。请参阅输出:{“ key”:“ value”}
。右键单击项目并选择导出→Java→可运行的JAR文件。
选择类的启动配置
com.example.main
和 库处理:[x]提取物需要库中生成的jar。点击 完成。尝试运行生成的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
Clone the project:
git clone [email protected]:haba713/eclipse-ivyde-export-issue.git
Import the cloned project into Eclipse workspace.
Right-click the class
src/com.example/Main.java
in the project tree and
choose Run as → Java Application. See the output:{"key":"value"}
.Right-click the project and choose Export → Java → Runnable JAR file.
Choose the launch configuration for the class
com.example.Main
and
Library handling: [x] Extract required libraries into generated JAR. Click
Finish.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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方法
我认为这是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.