How to create Java Executable JAR with JAR dependencies
The following video shows creating an executable JAR file with other JAR dependencies.
- Create a simple standalone java application, for instance a simple Swing UI application
with two dependent libraries (commons-lang3-3.0.1.jar and commons-io-2.1.jar).
- Compile and run the application for sanity.
- Create a manifest file with Main-Class and Class-Path attributes.
The library path is relative to the JAR root directory.
- Ensure to enter a new line at the end of manifest file.
Otherwise some systems may throw failed to load Main-Class error.
- Execute JAR command from the console (Ensure to include JDK_HOME\bin in Path environment variable).
- Run the executable JAR from the console and "Open with" windows dialog.
Download Source code for this article (2 KB)