Srikanth Technologies

Adding JAR to Local Repository

Generally we want Maven to download JAR files from public repository like Maven Central.

However, when required JAR is not available in any public repository, you can add that JAR to local repository and then refer to it POM.XML file.

I had to do it for Oracle JDBC Driver as it was not available in any public repository.

Here are the steps to add a JAR to local repository and use it in pom.xml file.
  1. Make sure you installed Maven
  2. Go to command prompt and run the following command to add OJDBC6.JAR to local repository:

    mvn install:install-file -Dfile=d:\software\java\ojdbc6.jar
                             -DartifactId=ojdbc6 -Dversion=11.0.0 -Dpackaging=jar
    We are adding OJDBC6.JAR with groupid and artifactid ojdbc6 and version 11.0.0. You can give different values, if you like. This will copy JAR file to local repository from where Maven can retrieve when needed.
  3. When you need to use OJDBC6.JAR in your maven project, add the following dependency in POM.XML file as follows:


It is also possible to use a JAR that is not available to Maven by adding it as External Jar in project. But it is better to add a JAR to local repository and use it as it will be properly included when we build project using Maven.

For more information about Maven, refer to Maven Guide to installing 3rd party JARs