如何导出具有外部 Jar 依赖项的 Eclipse 项目? [英] How to export an Eclipse Project with External Jar dependencies?

查看:34
本文介绍了如何导出具有外部 Jar 依赖项的 Eclipse 项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Processing 中,我想导入一个我用 Java 编写的库,该库封装了一个外部库(一个 .jar 文件).

In Processing, I'd like to import a library I've written in Java which wraps around an external library (a .jar file).

Processing 似乎导入了我自己的库,但是当我调用构造函数(它引用外部库中的某些类)时,我在 Processing GUI 控制台中收到一个 java.lang.NoClassDefFoundError.

Processing appears to import my own library, but when I call the constructor (which references some classes in the external library), I get a java.lang.NoClassDefFoundError in the Processing GUI console.

如果不是在我的 Eclipse 构建路径中包含外部 .jar,而是使用库的实际源代码并导出所有这些,Processing 不会抱怨.

If instead of including the External .jar in my Eclipse buildpath, I use the library's actual source code and export all of that, Processing does not complain.

我怎样才能打包这个项目,这样我就不必在我的 Eclipse 项目中包含所有库的源代码(而只包含 .jar 文件)?

How might I be able to package up this project so that I don't have to include all of the library's source code (and instead just include the .jar file) in my Eclipse project?

更新:根据 N.L.telaviv 的建议,我选择导出为 Runnable JAR.对我有用的是选择选项将所需的库复制到生成的 JAR 旁边的子文件夹中".在这里,在包含引用的 .jar 库的 .jar 输出位置旁边创建了另一个文件夹.

Update: As per N.L.telaviv 's suggestion, I chose to export as a Runnable JAR. What worked for me was to select the option "Copy required libraries into a sub-folder next to the generated JAR." Here, another folder is created next to where your .jar is output containing the referenced .jar libraries.

Update2:另一个有效的选项是将所需的库提取到生成的 JAR 中".这样做允许 JAR 在内部访问引用.似乎同样适用于 N.L.telaviv 的建议,但情况似乎并非如此.如果您不想有任何额外的文件,请选择此选项.如果您浏览 .JAR 文件,您会注意到外部库位于单独的包文件夹中.

Update2: The other option which works is "Extract required libraries into generated JAR." Doing so allows the JAR to access the references internally. It seemed as though the same would have worked with N.L.telaviv 's suggestion, but that does not appear to be the case. Choose this option if you don't want to have any extra files. You'll notice, if you explore the .JAR file, that the external library is in a separate package folder.

推荐答案

使用 Runnable JAR 文件导出选项.

Use the Runnable JAR file export option.

点击你的项目-export-java-runnable jar文件-选择打包需要jar中的库的选项

Click on your project - export - java- runnable jar file - select the option to pack requires libraries in the jar

这篇关于如何导出具有外部 Jar 依赖项的 Eclipse 项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆