Create Maven JAR in NetBeans IDE – Step by Step tutorial

It was my first Java project after several years of working with Linux and PHP. Fortunately, Maven with NetBeans saved my day. But what I felt was lacking with NetBeans is the ability to create Maven JAR file – yes, I couldn’t find an option to generate a Maven JAR using the IDE. Generally, you can simply right-click on Project and select Properties > Run and set main class to make an entry in MANIFEST.MF of the generated jar. But this will only create simple JAR and not Maven jar. It seems like creating Maven JAR is not a straightforward option in NetBeans – where you have to manually edit the configuration called pom.xml. POM stands for Project Object Model, which is an XML file containing information about the project and configuration details for Maven to build the project.

Creating JAR file in NetBeans

generate maven jar

How to generate Maven jar file in NetBeans?

1. In the Project window, double click pom.xml under Project > Project Files

maven jar netbeans

2. In pom.xml file, copy and paste the below code (just before the closing project tag)


3. Lookout for the tag <mainClass> and replace it with the main class of your project.

create maven jar

4. Save pom.xml

5. Now Build project and lookout for the jar files under target directory in PROJECT_HOME. (PROJECT_HOME is the directory where the project files are stored)

Once done, you should be able to run using the below command.

$ java -jar <generated_maven_jar>.jar

That’s it. Hope it helps someone out there.

Topics :

vps germany

Get Free Email Updates

Disclaimer: The content published in this article is the views of the author only. Techglimpse does not gurantee accuracy, completness or validity. If you believe the content on this post violates your copyright, please send us a mail for removal. Read more.