Sometimes you might need to package 3rd party JAR files in a way that allows you to incorporate them into a maven project easily.  To do so, you need to put the JARs in a local repository to so that the can be picked up by Apache maven. You can  achieve this by using the maven-install-plugin by running the following command:

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
-DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>

To illustrate this with an example, let us assume that we want to add the  Algorithms Book library to your local repository. You need download first the algs4.jar to your machine (i.e. ~/Downloads). Once you have done so, you can run the following command to add this file to your local repository.

mvn install:install-file -Dfile=~/Downloads/algs4.jar -DgroupId=edu.princeton.cs \
-DartifactId=algs4 -Dversion=1.0 -Dpackaging=jar

Once you added the jar file to the local repository. You can use the following XML in your project’s pom.xml.


Happy Coding.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s