问题
I'm trying to package some external libraries into my java project, but failing miserably. I've got a .jar-file, with external libraries packaged into ./lib/jars. If I have the manifest pointing the Class-Path: at lib/jars/theJar.jar, I get a NoClassDefFoundError. If I have the Class-Path pointing at C:\Users\Owner\workspace\theProject\lib\jars\theJar.jar, the jar file is found - but I suppose that will only work on my computer.
How do I make the program go looking for the jars inside of the jar?
回答1:
You don't, unless you use a custom classloader like JarClassLoader.
Alternatives include things like jarjar and One-JAR.
Edit It appears I misunderstood your problem, based on your question title--they're not really "internal", they're external, as your question correctly states. The last sentence is again misleading: are you trying to reference external jars, or jars inside of the jar?
来源:https://stackoverflow.com/questions/9573868/java-manifest-internal-jar-link