maven logo

How to install local jars into maven local repository

When you develop maven java project sometime you will get issue is some jars library that you need but not yet or not exist on maven center repository, so how you can make your project build work with these issues. In this post i will guide you how to install local jars into maven local repository.

To install local jars into maven local repository, you can use following command

mvn install:install-file

Where: <path-to-file>  the path to the file to load
       <group-id>      the group that the file should be registered under
       <artifact-id>   the artifact name for the file
       <version>       the version of the file
       <packaging>     the packaging of the file e.g. jar

To demonstrate for this command i will install to my maven local repository.

1. Maven install

Copy to directory that we want to read from in my example it is D:\ and run command below

mvn install:install-file -Dfile=D:\ -DartifactId=ssl -Dversion=1.0 -Dpackaging=jar

Sample output of this command

\>mvn install:install-file -Dfile=D:\
 -DartifactId=ssl -Dversion=1.0 -Dpackaging=jar
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom
[INFO] Installing D:\ to C:\Users\ThaiThinh\.m2\repository\co
[INFO] Installing C:\Users\THAITH~1\AppData\Local\Temp\mvninstall837714260042505
0833.pom to C:\Users\ThaiThinh\.m2\repository\com\sun\net\ssl\1.0\ssl-1.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.830s
[INFO] Finished at: Tue Mar 03 14:23:31 ICT 2015
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------

2. Use the library in local

To involve this library on your project, now we just need add follow dependent to our pom.xml file


Leave a Reply