Java Manifest file's class path and how it determines relative dirs

前端 未结 1 1774
广开言路
广开言路 2020-12-22 00:55

How does the Class-path in the MANIFEST.MF file determine the relative location?

1) Say I have a JAR with a jar inside lib/somejar.jar

相关标签:
1条回答
  • 2020-12-22 01:27

    When doing it "plain vanilla", you can't have a JAR inside a JAR. You need to either put it outside in a known path relative to the main JAR, or extract the JAR's contents in the main JAR.

    But since Eclipse 3.5 you can do this with a builtin trick. Check the 2nd Library Handling option when you choose Export > Runnable JAR file.

    alt text

    When choosing Package required libraries into generated JAR, then Eclipse will add a special classloader which will load those JAR's transparently for you before executing the main class. It's doing that with help of JarRsrcLoader.

    0 讨论(0)
提交回复
热议问题