Installing 3rd party JARs in Maven project

When working in Maven projects, sometimes we need to use some libs that aren’t found in any Maven repository. A common example of this situation is Oracle JDBC Driver.

We have at least three ways to solve this kind of situation:

1) Using <scope /> and <systemPath />

You just need to have the jar file in your project (or in any well known path) and include the Maven dependency informing as a system dependency.

For example, considering you have the ojdbc6.jar in a folder called lib:


2) Installing JAR via command line

You install the jar into your repository through command line and just refer the dependency inside your pom.xml like any other one.


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

3) Installing JAR via Maven plugin

I think this is not so common, but at least is an interesting option (actually, I used it just once). You can use the maven-install-plugin (the same used in command line) to install the jar during some Maven phase defined in the configuration. Besides that, you just need to put the normal dependency like any other one.

In the example below, we’re installing the odjbc6.jar during the clean phase:




Let me your thoughts

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s