0

I have created a package that is to be used by other programmers by importing in their code. my programs use other jar files for XML parsing and I don't want others to worry about the dependencies what is the best way to make sure that my jar files always gets its dependencies?

  1. Should i include the dependencies in my original jar?
  2. Is there any alternative way?
Shurmajee
  • 1,027
  • 3
  • 12
  • 35
  • 1
    see mvn solution http://stackoverflow.com/questions/9812209/maven-making-jars-with-dependencies-example-from-book-doesnt-work – farmer1992 Jan 15 '13 at 08:56

3 Answers3

2

I would say cleanest solution is to use bulid scripts like using Ant or Maven. In Maven you could create a local repository with the name of mayank. Now, all your team members just need to include dependency mayank; all other dependencies will automatically be downloaded. They dont have to worry about anything else.

Deepak Singhal
  • 10,568
  • 11
  • 59
  • 98
1
  1. If you want to release your source as a zip archive, I would keep the dependencies outside the project jar. For example in a folder name lib.

  2. I would use a build tool like Maven (http://maven.apache.org) to manage my dependencies. It's pretty easy to set up a repository like Nexus (http://www.sonatype.org/nexus) where your team members can get your jar and all the required dependencies.

mattis
  • 119
  • 1
  • 4
0

Use jarjar, seems doing exactly that you want, does not force your potential users to use exactly Maven (some may use old Ant scripts or IDE features to add .jar file directly).

Audrius Meškauskas
  • 20,936
  • 12
  • 75
  • 93
  • jarjar is not always a solution - you have to take care with the licenses bound to specific jars. You are not free to just rip and redistribute whatever you want however you want. – Gimby Jan 15 '13 at 09:06
  • There are no technical solutions for licensing problems. With any tool, you are not allowed to rip and redistribute whatever you want however you want! – Audrius Meškauskas Jan 15 '13 at 09:09