简体   繁体   English

如何导出具有外部Jar依赖项的Eclipse项目?

[英]How to export an Eclipse Project with External Jar dependencies?

In Processing, I'd like to import a library I've written in Java which wraps around an external library (a .jar file). 在处理中,我想导入一个用Java写的库,该库环绕一个外部库(一个.jar文件)。

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. 处理似乎是导入我自己的库,但是当我调用构造函数(它引用外部库中的某些类)时,在处理GUI控制台中得到了java.lang.NoClassDefFoundError

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构建路径中包括External .jar,而是使用该库的实际源代码并将其全部导出,那么Processing不会抱怨。

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? 我如何能够打包该项目,以使我不必在Eclipse项目中包括库的所有源代码(而只需包括.jar文件)?


Update : As per NLtelaviv 's suggestion, I chose to export as a Runnable JAR. 更新 :根据NLtelaviv的建议,我选择导出为Runnable JAR。 What worked for me was to select the option "Copy required libraries into a sub-folder next to the generated JAR." 对我有用的是选择选项“将所需的库复制到生成的JAR旁边的子文件夹中”。 Here, another folder is created next to where your .jar is output containing the referenced .jar libraries. 在这里,将在输出包含所引用的.jar库的.jar的旁边创建另一个文件夹。

Update2 : The other option which works is "Extract required libraries into generated JAR." Update2 :另一个可行的选择是“将所需的库提取到生成的JAR中”。 Doing so allows the JAR to access the references internally. 这样做允许JAR在内部访问引用。 It seemed as though the same would have worked with NLtelaviv 's suggestion, but that does not appear to be the case. NLtelaviv的建议似乎同样可行,但事实并非如此。 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. 如果浏览.JAR文件,您会注意到,外部库位于单独的包文件夹中。

Use the Runnable JAR file export option. 使用可运行的JAR文件导出选项。

Click on your project - export - java- runnable jar file - select the option to pack requires libraries in the jar 单击您的项目-导出-Java-可运行的jar文件-选择将所需库打包的选项

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Eclipse:如何使用带有外部项目依赖项的ant构建可执行jar? - Eclipse: How to build an executable jar using ant with external project dependencies? 如何导出将在另一个Java项目中使用的jar以及jar使用的整个maven /外部依赖关系? - How do I export a jar that will be used in another Java project, along with the entire maven/external dependencies that the jar uses? 使用非提供的依赖项导出jar Eclipse Maven Project - Export jar Eclipse Maven Project with just non-provided dependencies 使用Eclipse将具有外部依赖项的Java项目导出到jar - Exporting a Java project with external dependencies to a jar using Eclipse 如何在Eclipse中使用其他外部jar依赖项创建一个不可运行/不可执行的jar - how to create a not runnable/not executable jar with other external jar dependencies in Eclipse 在没有main方法(使用外部jar)的情况下将Java项目导出到Eclipse中的Jar - Export a Java project without main method (with external jars) to Jar in Eclipse 如何在Eclipse中导出Android库项目的jar - How export jar of a android library project in eclipse 如何从Eclipse导出Java jar并依赖其他jar? - How export Java jar from Eclipse with dependencies on other jars? 如何从 Eclipse 导出具有所有依赖项的可运行 JAR 文件? - How to export runnable JAR file from Eclipse with all dependencies? Eclipse PDE,如何访问和使用外部Jar依赖项 - Eclipse PDE, How to access and use external Jar Dependencies
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM