'Creating a jar from a maven project in intellij

I created a new maven project in IntelliJ and set packaging to jar but when I build it, the target folder does not contain a jar. I'm sure its something really dumb on my part but there are just so many different things i'm reading on different websites and I just feel better asking. enter image description here



Solution 1:[1]

You should build you project using IDEA's Maven Projects view.

View -> Tool Windows -> Maven Projects

or open it from left bottom corner menu:

menu

And then build your project with maven goals - i.e. package: maven project

If packaging is set to jar in pom.xml, you will get a jar in target dir.

Solution 2:[2]

Go to the maven project and double click clean and package.

For just do following:

enter image description here

Solution 3:[3]

You need the maven jar plugin in order to create a jar

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
        <archive>
            <manifest>
                <addClasspath>true</addClasspath>
                <classpathPrefix>lib/</classpathPrefix>
                <mainClass>add your main class</mainClass>
            </manifest>
        </archive>
    </configuration>
</plugin>

https://maven.apache.org/plugins/maven-jar-plugin/

Solution 4:[4]

You need to have "jar" in packaging section of your pom.xml. You can add this before dependencies section:

<packaging>jar</packaging>

Then go to View -> Tool Windows -> Maven and in Maven window expand everything and double click on "package" in Lifecycle section.

Solution 5:[5]

Assuming that the screen-shot shows the complete pom file, you are missing the entries that define the artifact. Try adding something like this following immediately after the tag:

  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mycompany.example</groupId>
  <artifactId>stackoverflow-question</artifactId>
  <version>0.0.1-SNAPSHOT</version>

You should end up with stackoverflow-question-0.0.1-SNAPSHOT.jar in your /target directory. You may need to refresh the directory to see it (You certainly have to in Eclipse)

Solution 6:[6]

You can use iu, this is my way

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Amr Lotfy
Solution 2 ankit
Solution 3 sethu
Solution 4
Solution 5 kiwiron
Solution 6 Dave Rincon