I have a program that needs several third-party libraries, and at the moment it is packaged like this:
zerobot.jar (my file)
libs / pircbot.jar
libs / mysql-connector-java-5.1.10-bin.jar
libs / c3p0-0.9.1.2.jar
As far as I know, the βbestβ way to handle third-party libraries is to put them in the classpath in the manifest of my jar file, which will work cross-platform, will not slow down the launch (this union they can) and do not encounter legal problems (which may be repackaged).
The problem is that users who themselves provide third-party libraries (use case, updating them to fix the error). Two libraries have a version number in the file, which adds to the hassle.
My current solution is that my program has a boot process that creates a new class loader and runs the program using it. This custom classloader adds all .jar files in lib / to its classpath.
My current method works fine, but now I have two custom class loaders in my application, and a recent code change has caused problems that are difficult to debug, so if there is a better way, I would like to remove this complexity. It also seems like over-designing as I am sure this is a very common situation.
So my question is: how do I do this?
java classpath jar dependencies packaging
ZoFreX
source share