File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Ant, Maven and Other Build Tools and the fly likes Including Local  Jar Files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Including Local  Jar Files" Watch "Including Local  Jar Files" New topic

Including Local Jar Files

Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 641

I have some jar files those are not part of any global repos, i have to include them in my war thats build by Maven, on some googling i found following task

but this does not put the jar file in war...also its not recommended solution, does any one have better way to achieve this?


All desirable things in life are either illegal, banned, expensive or married to someone else !!!
Joachim Rohde
Ranch Hand

Joined: Nov 27, 2006
Posts: 428

Deploy the JAR file into your local repository:

Or install a repository manager like, e.g.
Peter Johnson

Joined: May 14, 2008
Posts: 5852

Here is what I do. I add the dependencies to my pom.xml and run mvn. I then get an error about the missing dependencies along with the full command needed to register the JAR files in my local repository. I enter those commands, the JARs go into the local repository and then I run mvn again and everything compiles.

The easy part is coming up with a reasonable mechanism for specifying the group id (I usually use the first few levels of the class package), artifact id (I used the library name) and version in the dependency. The hard part is that you have to manually handle transitive dependencies (aaa.jar depends on bbb.jar, but the app needs only aaa.jar to compile).

JBoss In Action
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 641
Thanks much Peter and Joachim, I am good now.

I agree. Here's the link:
subject: Including Local Jar Files
It's not a secret anymore!