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).
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.
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
- How to create a jar with external libraries included in Eclipse?
- how to create a not runnable/not executable jar with other external jar dependencies in Eclipse
- How to export an Eclipse Project with External Jar dependencies?
- How to create runnable jar with resources in Eclipse from Maven project
- How do you debug an external jar with eclipse that has byte code?
- how to update a external jar with my java class file on eclipse
- How to Specify External log4j2 Config File in Runnable jar Created with Eclipse
- How to refresh Eclipse RCP plugin with jar libraries
- How to create a Runnable Jar File on Mac with Eclipse
- How to create executable jar with standalone HSQLDB in Eclipse
- How to Export Runnable Jar from Eclipse with external NON text file. Encrypt & Decrypt Certificates in src folder
- Exporting Runnable JAR in eclipse with User Libraries included
- How to create a runnable jar with the eclipse jdt API?
- How to create jar with aspectj? Eclipse
- Eclipse create java executable with external libraries
- Eclipse how to link a jar containing javadocs/source with its binary?
- How can Eclipse create a class with unresolved compilation problems?
- Eclipse: How to build an executable jar with external jar?
- How to create the pom.xml for a Java project with Eclipse
- How do I build a Java project in Eclipse, to create an external JAR
- How do I create a runnable JAR in IntelliJ as I would in Eclipse
- How to create Jar file from Maven project in eclipse
- how to create jar file using eclipse
- How to create a generic list with Eclipse EMF?
- How to add Android libraries with resources without using Eclipse
- how to create an eclipse workspace with command line without actually launching eclipse?
- Exporting to Runnable jar with extra native code libraries in eclipse
- How do you build a JAR in eclipse with a custom manifest file?
- How to create a Maven project in Eclipse with AspectJ support?
- How do I create a Spring Boot Starter Project in Eclipse that is properly configured with a Run Configuration?
More Query from same tag
- Eclipse RCP - Stacking a view with the editor area?
- Google Analytics API DataQuery object
- Change Colours In Eclipse Diff
- Unable to retrive data from SQLite says column doesn't exists in android (Eclipse)
- Instruments crashed on startup iPad Mini
- how to solve jsp error?
- Adding folder in eclipse in src directory without making it package
- java.lang.ClassNotFoundException: com.sql.jdbc.Driver
- wsimport issue in ANT task
- Is it really safe to have an unsynchronized static BundleContext reference in the BundleActivator?
- Jgit- How to get list of merge commits between two dates using Jgit?
- Coffeescript text highliting with Eclipse
- Drawing a bufferedimage slow in Windows, fast in Linux
- Error in Preview of Custom Eclipse refactoring
- Eclipse/Java9: how to access internal javafx packages?
- How to create a new android project without using support libraries?
- BPMN error in eclipse activiti
- Determining if an IFolder is a Java output folder
- Keeps track of files in eclipse, who made changes on which branch
- Why am I getting 7 hours extra when I time something using this code?
- wrong include paths in eclipse after updating ndk
- Hiding nodes in the model tree of EMF Compare
- How to ignore resource xml files in android project settings
- Adding Builders to Project in Eclipse and Incremental-ness
- Tomcat Deploying 2 Projects
- Hibernate InvalidMappingException when running jar-packed application
- I got error when click on file java or xml file in android - Eclipse
- Debug C++ code in visual studio from python code running in eclipse