Installing External Jars to Local Maven Repository

Central Maven repository has a large variety of libraries https://mvnrepository.com however there are times that we may be in need of installing such 3rd party jars that are not offered in the central in mavenized projects. This command will allow you to install such jars to your local M2 folder. You need to make sure that if multiple developers are working on the project that experiences this situation, the participants must also carry out the same procedure.

The Command

[bash lang=”bash” smarttabs=”true” tabsize=”4″ wraplines=”true”]mvn install:install-file -Dfile={FILELOCATION}
-DgroupId=GROUPID/KNOWNASPACKAGENAME -DartifactId=ARTIFACTID
-Dversion=VERSION -Dpackaging=PACKAGINGTYLE[/bash]

Example Command

[bash smarttabs=”true” tabsize=”4″ wraplines=”true”]mvn install:install-file -Dfile=C:\myjar1-0.jar
-DgroupId=com.tugrulaslan -DartifactId=MyJar
-Dversion=1.0 -Dpackaging=jar[/bash]

Usage in pom.xml

<dependency>
<groupId>com.tugrulaslan</groupId>
<artifactId>MyJar</artifactId>
<version>1.0</version>
</dependency>

External Links
https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

Leave a Reply

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