How to add local jar files to Maven project

Sometimes you need to include the custom JAR file or the JAR that you want to use and it doesn’t exist in maven central repository in your Maven project. To resolve this type of problem you can define the local/system JAR file location in the dependency tag.

For example, to connect with Oracle database you need the ojdbc.jar jar file but this file doesn’t exist in the maven central repository. But now you can pass the local jar file location in your pom.xml.

Below dependency code will include the local jar file to your maven project.

    <!-- <systemPath>F:/lib/ojdbc14.jar</systemPath> -->

${basedir} represents the directory containing pom.xml.

Note: by adding the dependency as system scope and refer to it by its full path is not best approach.

Similar Posts

About the Author

Atul Rai
I love sharing my experiments and ideas with everyone by writing articles on the latest technological trends. Read all published posts by Atul Rai.