0

In my project I'm using many jar fiels to support the project..as the number of jar files increases I want to move all jar files into a single jar and make use of that.can you provide me useful links that can help me to do this.

Cœur
  • 37,241
  • 25
  • 195
  • 267
snehalakshmi
  • 53
  • 3
  • 8

3 Answers3

3

Plenty of options -

In Eclipse you can

  • Create a normal java project with a sample main class
  • Add jar files to the project
  • Export it as a runnable jar, which should repackage the all the jars into one.

Do it through an ant task -

<jar destfile="combined.jar">
  <zipgroupfileset dir="lib" includes="*.jar" /> 
</jar>

More tools like jarjar, onejar (and many more) etc are available to do the repackaging.

Jayendra
  • 52,349
  • 4
  • 80
  • 90
2

If you are willing to use ant (which can be called from Eclipse) there are some solutions in this other question here: Clean way to combine multiple jars? Preferably using Ant

I also like proguard, which combines jars and also strips out unused code.

Community
  • 1
  • 1
Eamonn O'Brien-Strain
  • 3,352
  • 1
  • 23
  • 33
0

I would recommend you use a maven pom file to maintain your dependancy's. It has a pretty steep learning curve at first, but once you get the hang of it it makes your life so much easier. You would just add all your dependencies in the pom and maven would download and maintain them itself.

steelshark
  • 644
  • 4
  • 10