Building an artifact in Intellij and include libraries

Some time ago, I wanted to build a JAR-file containing an external library (more specifically a JDBC-driver for SQLite) in Intellij. This sounds easier than it is and after some searching I finally found a solution to why my JAR-file couldn't find the library after building the artifact.

First of all, open up the module settings dialog by pressing "ALT + CONTROL + SHIFT + S" (on Windows/Linux) and find the tab "modules" (see the screenshot below).

Module settings dialog

Open the tab "dependencies" and tick the checkbox before all libraries that are needed by your JAR.

Dependencies tab

Now, head over to the "Artifacts tab" (in the left pane), click the green plus and choose for "JAR" > "From modules with dependencies".

Create JAR

The following screen should appear. Select the correct Main-class and press OK.

Create JAR

After you've pressed OK, the following screen appears. This is the final step. Just press OK and start building your artifact!

Create JAR

Post created by Pieter Verschaffelt on 2016-06-28 10:41:59