Quickly create Jar artifact for application
August 20th, 2010 by Nikolay ChashnikovSince the last EAP build IntelliJ IDEA X provides an action to quickly create a single Jar artifact containing your modules with all dependencies. Just press ‘+’ button in the Project Structure dialog and select the appropriate item:
IntelliJ IDEA shows a dialog allowing you to customize the artifact:
After that you can build the Jar file using Build | Build Artifact menu item.
Note that by default all libraries are extracted to the target Jar. It became possible with addition of the new Extracted Directory element. Using such element you can extract a directory from a Jar file and place it into the output of your artifact:

Tags: ideaX

August 28th, 2010 at 6:40 am
The path of manifest file is not update when we add or remove librairies or change directory of librairies (move) . It’s too domage :s
Duto
October 3rd, 2010 at 9:46 pm
Having issue runnin JAR packaged via IDE. Get the following error
“Exception in thread “main” java.lang.SecurityException: Invalid signature file”
Any ideas what could be wrong?
July 5th, 2011 at 11:15 am
in previous version of intellij it was easay to build a jar: now it is extremely non intuitive!
the main problem is that I build a different jar for each module without dependencies!!!
how do you do that?
not obvious
December 3rd, 2011 at 11:26 am
Please tell me where is created jar-file ??? I can not find it in the project folder.
December 5th, 2011 at 1:35 am
Denis,/out/artifacts directory.
path to the jar file is specified in ‘Output directory’ in the artifact settings. By default it is under
December 29th, 2011 at 9:17 pm
I am trying to create jar file. My project contains external csv files outside src folder that is essential for the project. But when running the jar file it seems as though they are not being involved.
Any Idea
December 30th, 2011 at 7:07 am
bipul,
files outside source roots aren’t included into jar file by default. However you can add them by hand: open the artifact settings in Project Structure dialog, press ‘+’ button under ‘Output Layout’ tab, select ‘File’ item and choose the desired files.
January 17th, 2012 at 4:43 pm
Hi, sorry for my english. How can i exclude a single file from the jar created in that way?
January 23rd, 2012 at 3:10 am
Pepe,
it isn’t possible now. However you can move that file to a separate module. This way you also ensure that other files don’t depend on the excluded file.
June 23rd, 2012 at 9:54 am
When I try to run the jar executable, I get the ‘Could not find main class. Program will exit’ error. I used the browse tool to locate the Main Class, in Project Structure>Artifacts, but nothing I have tried putting in the Class Path text field seems to properly locate the class file (even leaving it empty).
The main class is in the first package folder in src, so src/package1/MainProgram.
The Main Class field reads package1.MainProgram
I have tried relative and absolute path names for the Class Path, but nothing works. Currently it is: out/production/ProjectName/package1/
What am I doing wrong?
July 31st, 2012 at 3:59 pm
Hello Team,
I am also receiving this error when running the jar from the Terminal.
“Exception in thread “main” java.lang.SecurityException: Invalid signature file digest for Manifest main attributes”
What am I doing wrong?
August 20th, 2012 at 1:11 pm
Solution for “java.lang.SecurityException: Invalid signature file digest for Manifest main attributes”
The problem is that one of the jars you extracted was signed. You could link the jars up instead of extracting them, but that’s not nice if you just want one jar file to run and share. I solved this with an ant post-processing task like this. Just change output.jar to the right name for your artifact.
August 20th, 2012 at 1:13 pm
Whoops, can’t paste XML into here. Here’s the ant build target: https://gist.github.com/3406283
October 15th, 2012 at 12:31 pm
I am now packaging my app to a jar and this is working great, thanks! Unfortunately I have a network copy step in my deployment to test servers and I would rather not send the entire groovy distribution every time I send a new iteration out. Is there a recommended way to send out an executable “my code only” jar which references the all in one?