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\
Idea 8.1.3
Jar is ok, since there is compiled output in 'output' directory (project/out/production//)
I guess, you have to run 'make' before building jar
for dependencies just check "show library" and choose what you want.
Some of the other answers are useless because as soon as you re-import the IntelliJ IDEA project from the maven project, all changes will be lost.
The building of the jar needs to be triggered by a run/debug configuration, not by the project settings.
Jetbrains has a nice description of how you can accomplish this here:
https://www.jetbrains.com/help/idea/maven.html
Scroll down to the section called "Configuring triggers for Maven goals".
(The only disadvantage of their description is that their screenshots are in the default black-on-white color scheme instead of the super-awesome darcula theme. Ugh!)
So, basically, what you do is that you open the "Maven Projects" panel, you find the project of interest, (in your case, the project that builds your jar,) underneath it you find the maven goal that you want to execute, (usually the "package" goal creates jars,) you open up the context menu on it, (right-click on a Windows machine,) and there will be an "Execute before Run/Debug..." option that you can select and it will take you by the hand from there. Really easy.
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...
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
When i use these solution this error coming:
java -jar xxxxx.jar
no main manifest attribute, in xxxxx.jar
and solution is:
You have to change manifest directory:
<project folder>\src\main\java
change java to resources
<project folder>\src\main\resources
You might want to take a look at Maven (http://maven.apache.org). You can use it either as the main build process for your application, or just to perform certain tasks through the Edit Configurations dialog. The process of creating a JAR of a module within Maven is fairly trivial, if you want it to include all the dependencies in a self-executable JAR that is trivial as well.
If you've never used Maven before then you want to read Better Builds With Maven.
In case you are trying to build a jar with kotlin you need to create a src/main/java
folder and use this folder as a location for the META-INF folder.