Last modified date

Comment: 1

What is Maven?

Maven is a build automation tool used mainly for Java projects but it can also be used for other projects written in Scala, C# and other languages.

Installing Maven on a Mac or Linux

The easiest way to install Maven is to use Homebrew.

Install Homebrew using the command:

/bin/bash -c "$(curl -fsSL"

Then to install Maven, you can run the brew command brew install maven

What is the difference between GroupId and ArtifactId in a Maven project?

Group Id specifies the Id of the project group and uniquely identifies your project across all projects within a group.

It should follow the reversed domain name Java naming convention rules for packages. e.g. com.jaktech.myproject

Artifact Id is simply the name of the jar that is produced without the version. e.g. jaktech


How to generate a jar file in Maven

The simplest method for generating the .jar file from your Java project is by using the mvn clean install command.

Importing local jar file into Maven project

If you have a jar file locally that you need to import into your Maven project, you can do so by adding it as a dependency.

Working method

Open a terminal to the root of the project.

Then run the following command:

mvn install:install-file \
-Dfile=<<PATH TO JAR FILE>> \
-DgroupId=<<GROUP ID>> \
-DartifactId=<<ARTIFACT ID>> \
-Dversion=<<VERSION NUMBER>> \
-Dpackaging=<<PACKAGING TYPE E.G. JAR>> \

If you are using Intellij, you will be able to see the installed jar file in the External Libraries section in the project view.

Deprecated method

If your project is structured like this:

- my_maven_project
   |--> pom.xml
- my_jar_file

Then the dependency can be added in the following way.


If the Jar file is located somewhere else on your pc, then you can use the absolute path to reference the jar file.




1 Response

Leave a Reply

Your email address will not be published. Required fields are marked *

Post comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.