Install 3rd party JARs into Maven local repository

Sometimes, you want to include a JAR file into your maven project but this JAR file does not exist in any public repository. In this case, you need to install this JAR file into your local repository.

Below is a command to install a JAR file into your maven local repository:

Plain Text

For example, below is a command to install mylib.jar file (located in the C drive) into username John’s maven local repository.

Plain Text

After the above command is executed successfully, mylib-1.0.jar file is created at C:\Users\John\.m2\repository\mylib\mylib\1.0

Then John can reference this library in his maven project by declaring the dependency tag below in his pom.xml file:

<dependency>
    <groupId>mylib</groupId>
    <artifactId>mylib</artifactId>
    <version>1.0</version>
</dependency>