How to include library manually into maven local repository?
There are still many Java libraries are not supported Maven, and may be you created a custom library which is required to include it into Maven local repository. Fortunately, Maven comes with command to let you include your “non-maven-support” library into Maven local repository easily.
Case study
For example, “kaptcha” is a third party library which is used to generate “captcha” image, but it did not support Maven. Here’s a guide to show how to install the “kaptcha” jar into your Maven’s local repository.
1. Install “non-maven-support” library
Download the “kaptcha” jar file and put it into c drive, and issue the following command.
mvn install:install-file -Dfile=c:\kaptcha-2.3.jar -DgroupId=com.google.code -DartifactId=kaptcha -Dversion=2.3 -Dpackaging=jar
Result
D:\>mvn install:install-file -Dfile=c:\kaptcha-2.3.jar -DgroupId=com.google.code -DartifactId=kaptcha -Dversion=2.3 -Dpackaging=jar [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'install'. [INFO] ------------------------------------------------------------------------ [INFO] Building Maven Default Project [INFO] task-segment: [install:install-file] (aggregator-style) [INFO] ------------------------------------------------------------------------ [INFO] [install:install-file] [INFO] Installing c:\kaptcha-2.3.jar to D:\maven_repo\com\google\code\kaptcha\2.3\kaptcha-2.3.jar [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: < 1 second [INFO] Finished at: Tue May 12 13:41:42 SGT 2009 [INFO] Final Memory: 3M/6M [INFO] ------------------------------------------------------------------------
In will include the “kaptcha” jar library into your Maven local repository.
2. Modify pom.xml file
After installed, you can add the custom library details into the “pom.xml” file.
<dependency> <groupId>com.google.code</groupId> <artifactId>kaptcha</artifactId> <version>2.3</version> </dependency>
3. Done
Build it, now the “kaptcha” jar is retrieve from your Maven local repository.



[...] Install library into Maven local repository Oracle Magazine (Free) Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. [...]
Thanks a lot!!!!!
it was really a great. Simple and easy as everything must be.
Thanks a lot… Your steps were simple and very helpful…
Thanks for the detailed simple steps!!!
[...] P.S For custom library, you need to install it into your Maven Local Repository manually. [...]
Thanks a lot for your effort. It helped a lot. Thanks!
Make sure to add -Dpackaging=jar to that mvn:install command. This parameter is not optional. (In your instructions, it appears in the result section, but not in the command)
hi -Dpackaging=jar is a must in order for the install the mavan library manually into our local repository. Post is updated , thanks for it.