How to create a jar with external libraries includ

2018-12-31 16:02发布

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

标签: java eclipse jar
8条回答
与君花间醉酒
2楼-- · 2018-12-31 16:24

While exporting your source into a jar, make sure you select runnable jar option from the options. Then select if you want to package all the dependency jars or just include them directly in the jar file. It depends on the project that you are working on.

You then run the jar directly by java -jar example.jar.

查看更多
姐姐魅力值爆表
3楼-- · 2018-12-31 16:26

You could use the Export->Java->Runnable Jar to create a jar that includes its dependencies

Alternatively, you could use the fatjar eclipse plugin as well to bundle jars together

查看更多
登录 后发表回答