Search code examples
javaimportjardependenciesexport

How could I repack a jar file with all of its dependencies?


I am developing an application which is supposed to run standalone. However, this project involves a .jar file which contains a lot of dependencies, and if I simply distribute this .jar file with the application, it won't work.

I wonder if there is any way in which I could unpack the file, add the dependencies and repack it again? I hope there are some automatic mechanism for this, since the manual process could take hours, and there might be other referenced jar files.

P.S. I am using Eclipse, but since I am going to deploy this project with Web Start, exporting the project with the build-in export tool might not be a good idea since my attempts all ended up with ClassNotFoundException, so I suspect I might have to pack the project into several jars.

Thanks!


Solution

  • Have a look at jar jar. It sounds like it will do what you need.