Accepted answer

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 , cannot be included (for maven projects, search here).


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.


if it is a standalone (main method) java project then not any specific path put all the jars inside the project not any specific path then right click on the project - > export - > runnable jar --> select the lunch configuration and library handeling then choose the radio button option "package required libraries into generated jar" -- > finish.


if you have a web project then put all the jars in web-inf/lib folder and do the same step.


to generate jar file in eclipse right click on the project for which you want to generate, select export>java>runnable jar file,

enter image description here

enter image description here

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.


if you want to export all jar-files of a java web-project, open the latest generated war-file with a zip-tool (e.g. 7-zip), navigate to the /web-inf/lib/ folder. here you will find all jar-files you need for this project (as listed in "referenced libraries").



none of the answers above worked for me, i still kept getting noclassdeffound errors (i am using maven for dependencies). my solution was to build using "mvn clean install" and use the "[project]-jar-with-dependencies.jar" that that command creates. similarly in eclipse you can right click the project -> run as -> maven install and it will place the jars in the target folder.


you can right-click on the project, click on export, type 'jar', choose 'runnable jar file export'. there you have the option 'extract required libraries into generated jar'.


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

Related Query

More Query from same tag