How to add local jar to a Maven build

Maven manages the dependencies by downloading from central repositories, but many times we need to use jar’s which are not part of these central repositories. Let’s see how to add support for these jar’s in our Maven build. We shall use the simple maven project that we create in the post How to create a simple Java project in Maven

Folder Structure

We shall use the same folder structure from our post and add a folder called lib to store the jar locally. Here is how it would look

maven-local-jar

Here we see that codezuzu-util-1.0.jar is not available in maven central repo and we want to use the same. Let’s see the changes that we need to do in the pom.xml to use it.

See the highlighted lines, we use the scope as system and specify the system path where the jar can be found.

Leave a Reply

Your email address will not be published. Required fields are marked *