How to create a jar with external libraries included in Eclipse?

后端 未结 8 1460
北恋
北恋 2020-11-22 10:46

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

相关标签:
8条回答
  • 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.

    Package libraries

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

    0 讨论(0)
  • 2020-11-22 11:25

    To generate jar file in eclipse right click on the project for which you want to generate, Select Export>Java>Runnable Jar File,

    Its create jar which includes all the dependencies from Pom.xml, But please make sure license issue if you are using third-party dependency for your application.

    0 讨论(0)
提交回复
热议问题