Convert jar to pom dependency

Do you have a jar file which you’d like to use in your maven project but don’t know how? If you’re confused as to how to go about this then this tutorial is for you.

In order to convert or add a third party jar as a pom dependency, You need to have maven installed on your local computer.

You first need to have java jdk minimum 1.7 or above installed on your local computer in order to install maven.

Once you have java jdk installed, head over to this site and under files select Binary zip archive to download

Once downloaded, extract the archive to a location on your local machine that you can easily reference. Eg. C:\apache-maven-3.6.1

Now setup M2_HOME in your environment variables by adding M2_HOME as a System variable with variable name as M2_HOME and variable value as the root path of the extracted archive.


Now add the maven bin directory path as a Path variable under system variables. Eg. C:\apache-maven-3.6.1\bin .

You will need to verify that you have now installed and configured maven on your local machine. To do this run command prompt and enter the following command: mvn –version

If you see a similar thing like the image above on your screen, it confirms you have maven installed.

Now onto the real deal! The main reason for this tutorial. Locate and copy the path of the jar file. Run command prompt and enter this command

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

Replace <path-to-file> with the path to your jar file Eg. C:\Users\Documents\juggernut.jar, <group-id> with your group id Eg. com.techobbyist , <artifact-id> with your artifact id Eg. juggernut which is the name of my jar file, <version> with the version number of your jar file Eg. 1.0 and <packaging> with the type of file which in this case is a jar. Eg. jar.

Hit Enter to run the command . You will get the message BUILD SUCCESS if the process was successful.