Tuesday, October 23, 2012

How to include custom jar into your Maven repository?

Still you will find jars which are not there in Maven repository. Classic example is suppose you create a common utility jar and you want to use it across projects or it could be a third party jar which has private licence and so cannot be there in Maven central repository. In above cases, you can actually put the required jar easily in the Maven local repository. For demonstration purpose, we are using Kaptcha.
Here is the command:
mvn install:install-file 

Remember to remove the newlines from above command incase you are copying and pasting.
Below is the result from command line after executing the command:
C:\>mvn install:install-file -Dfile="c:\kaptcha-2.3.2.jar" -DgroupId=com.google
-DartifactId=kaptcha -Dversion=2.3.2 -Dpackaging=jar
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO] --- maven-install-plugin:2.3.1:install-file (default-cli) @ standalone-po
m ---
[INFO] Installing c:\kaptcha-2.3.2.jar to C:\Users\dharmvir.singh\.m2\repository
[INFO] Installing C:\Users\DHARMV~1.SIN\AppData\Local\Temp\mvninstall71581647865
23828175.pom to C:\Users\dharmvir.singh\.m2\repository\com\google\kaptcha\2.3.2\
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.587s
[INFO] Finished at: Tue Oct 23 15:23:57 IST 2012
[INFO] Final Memory: 3M/15M
[INFO] ------------------------------------------------------------------------
Job is done. You can now specify the dependency of this jar as shown:



  1. When I use this to install some custom jar, will I be able to build and deploy my project on an applicationserver without any further configuration?

  2. I have read your blog its very attractive and impressive. I like it your blog.

    Java Training in Chennai Core Java Training in Chennai Core Java Training in Chennai

    Java Online Training Java Online Training Core Java 8 Training in Chennai Core java 8 online training JavaEE Training in Chennai Java EE Training in Chennai