Creating a Java application that downloads its own dependencies
I'm interested in how to distribute a Java application that has a lot of dependencies (specified in a pom.xml in Maven).
Obviously it would be possible to just package everything in one big .jar file. However that seems wasteful, since an update of the application would require sending a new copy of all the dependencies as well.
So I'm looking for a way of distributing the app that does the following:
- Only includes the core application in the main .jar file
- Downloads dependencies as needed when the .jar file is run
- Keeps copies of the dependencies locally, so that if an application update is distributed the dependencies don't need to be downloaded again
What's the best way of achieving this?
you can distribute your file using the web start technology (aka distribute a jnlp file). i believe this will handle most of this functionality for you, including updatability.
Can you just use Maven, with something like described at Maven Run Project ?
This is how I have some of my own applications setup within my own network. I've never needed to worry about messing with the classpaths or downloading / providing dependencies for programs setup like this for a long time. This approach also meets all of your criteria.