I have multiple JAR files, which I have to add to classpath in Eclipse.
Is it possible to combine 30 files in one file and include that file?
First, you can. JAR is just a ZIP file. You can extract all stuff into one directory, then create zip file (even manually using WinZip or similar tool), call the result *.jar (if you wish) and add it into the classpath.
The only problem that will probably happen is if several jar files contain resources with the same name (and path). for example, manfest.mf, or other descriptors. In most cases it will not cause any problem but sometimes if application code uses these resources you can have trouble.
There are some automatic tools that do this. Take a look on JarJar.
BUT the more important question: why do you want to do this? If you do not use maven put all library jars to one directory named lib under your project. Then add all these jars to your classpath in eclipse using 2-3 clicks. That's it.
if you are using maven, include all your direct dependences into your pom.xml, compile the project, then say mvn eclipse:eclipse
. This will create .classspath and .project for you. Now just use it.
You can, but I don't think it would necessarily be a good idea to do so. Three possible reasons, and no doubt there are more:
My vote is to keep the jar files separate.
There are a number of existing tools for this:
The jarjar project is what you need.
Your may want to have a look at jarjar.
If you use an ant task you can also go for zipgroupfileset
:
<zip destfile="jarlibrary.jar">
<zipgroupfileset dir="lib" includes="*.jar"/>
</zip>
This question seems probable duplicate. Please try to find answer from similar article in this forum Clean way to combine multiple jars