How to add 3rd Party/Custom/External Jars to Maven Project?


In below steps will show about to add 3rd party/custom/external Jars in local repository for use in our project builds because these jars doesn’t exist in Maven public repository and required to build project.

Pre-Requisite

To add these jars we can use below command to load in local repository (.m2/repository)

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

Example : Oracle is 3rd party and it’s jars are available in maven public repository. We can use below command to store in maven local repository and make entry in pom.xml to use it.

mvn install:install-file -Dfile=C:\\Workspace\\ojdbc6.jar -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0 -Dpackaging=jar

pom.xml entry for above oracle jar

<dependency>
	<groupId>com.oracle</groupId>
	<artifactId>ojdbc6</artifactId>
	<version>11.2.0</version>
</dependency>

About Saurabh Gupta

My Name is Saurabh Gupta, I have approx. 10 Year of experience in Information Technology World manly in Java/J2EE. During this time I have worked with multiple organization with different client, so many technology, frameworks etc.
This entry was posted in Java, Maven and tagged , , , , , . Bookmark the permalink.