Possible Duplicate:
Can you add multiple jars in a jar file and then launch that jar file
I would like to find a way to embed a jar file into an executable jar file so all the utilities required for the program are contained in the jar file.
This URL describes what I want to do, but says it is only possible by writing a custom class loader:
http://docs.oracle.com/javase/tutorial/deployment/jar/downman.html
Even tho that URL is discouraging, I am not giving up.
The specific .jar file that I want to embed is the groovy.jar file.
Specifically, I would like my jar file to look like this:
jar -tf MyProg.jar
META-INF/
META-INF/MANIFEST.MF
lib/groovy-all-1.6.9.jar
MyProg.class
And I would like to execute like this:
java -jar MyProg.jar
Where MyProg.class is a groovy program, and groovy is not installed on the computer that runs java -jar MyProg.jar
I have been successful at exploding the groovy.jar file within the MyProg.jar file, but that is messy.
Does anyone have a custom class loader that does what I want?
Does anyone have any other ideas?
You can’t bundle different jars together easily as the class path entry of the manifest file only references jars outside of your jar itself.
Some tools may help you to change your jar and change its class loading mechanism. See why your question is closed.