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

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

问题描述

在处理中,我想导入一个用Java编写的库,它包装着一个外部库(.jar文件)。



处理出现要导入我自己的库,但是当我调用构造函数(引用外部库中的一些类)时,我在Processing GUI控制台中得到一个 java.lang.NoClassDefFoundError



如果不是在我的Eclipse buildpath中包含External .jar,我使用库的实际源代码并导出所有这些,Processing不会抱怨。

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






更新:根据NLtelaviv的建议,我选择以Runnable JAR。对我来说有用的是选择将所需的库复制到生成的JAR旁边的子文件夹中选项。在这里创建另一个文件夹,其中.jar的输出包含引用的.jar库。



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

解决方案

使用Runnable JAR文件导出选项。



点击你的项目 - export - java- runnable jar文件 - 选择在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 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.

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.

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?


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: 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.

解决方案

Use the Runnable JAR file export option.

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

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

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