Skip to content
Advertisement

How to build jars from IntelliJ properly?

I have a project that contains a single module, and some dependencies. I’d like to create a jar, in a separate directory, that contains the compiled module. In addition, I’d like to have the dependencies present beside my module.

No matter how I twist IntelliJ’s “build jar” process, the output of my module appears empty (besides a META-INF file).

Advertisement

Answer

Here’s how to build a jar with IntelliJ 10 http://blogs.jetbrains.com/idea/2010/08/quickly-create-jar-artifact/

File -> Project Structure -> Project Settings -> Artifacts -> Click green plus sign -> Jar -> From modules with dependencies...

Select a Main Class (the one with main() method) if you need to make the jar runnable.

The above sets the “skeleton” to where the jar will be saved to. To actually build and save it do the following:

Extract to the target Jar

OK

Build | Build Artifact | Build

Try Extracting the .jar file from

ProjectName | out | artifacts | ProjectName_jar | ProjectName.jar

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement