如何使用Eclipse中包含的外部库创建jar? [英] How to create a jar with external libraries included in Eclipse?
问题描述
将项目导出为一个Runnable jar(右键单击项目 - >导出 - > Runnable jar),您可以选择将所有依赖项打包到生成的jar中。它还有另外两种方法(见屏幕截图)导出您的库,在决定使用哪种打包方法时,请注意许可证。
启动配置下拉列表中包含一个包含 main(String [])
方法的类。导出为可运行的jar使用您的构建路径上的依赖关系(右键单击项目 - >构建路径 - 运行'jar。
>配置构建路径...)。当您导出为常规(不可运行)jar时,您可以选择项目中的任何文件。如果您的项目文件夹中有这些库,可以包含它们,但可以包含外部依赖关系,例如 maven ,不能包含(对于maven项目,在这里搜索<一>)。
I am done with the project which connects to database (MySQL). Now I want to export the project as jar. But I don't know how to include its external dependencies? Is there any way of doing it in Eclipse or should I use any scripts for that?.
When you export your project as a 'Runnable jar' (Right mouse on project -> Export -> Runnable jar) you have the option to package all dependencies into the generated jar. It also has two other ways (see screenshot) to export your libraries, be aware of the licences when deciding which packaging method you will use.
The 'launch configuration' dropdown is populated with classes containing a main(String[])
method. The selected class is started when you 'run' the jar.
Exporting as a runnable jar uses the dependencies on your build path (Right mouse on project -> Build Path -> Configure Build Path...). When you export as a 'regular' (non-runnable) jar you can select any file in your project(s). If you have the libraries in your project folder you can include them but external dependencies, for example maven, cannot be included (for maven projects, search here).
这篇关于如何使用Eclipse中包含的外部库创建jar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!