Executable JAR ignores its own Class-Path attribute

后端 未结 3 1105
-上瘾入骨i
-上瘾入骨i 2020-12-08 23:18

I used the instructions found at Maven - how can I add an arbitrary classpath entry to a jar to add an arbitrary entry to the Class-Path attribute. Here is my <

3条回答
  •  情歌与酒
    2020-12-08 23:31

    Answering my own question:

    1. Adding arbitrary entries to Class-Path is fine on its own. The problem arises when you enable JAR indexing using:

      
        
          true
        
      
      

      Maven will omit your entries from META-INF/INDEX.LIST.

    2. When you use the JAR at runtime, Java will look at INDEX.LIST for finding classes, not MANIFEST.MF.

    3. Because your entries are missing from INDEX.LIST, they will not be found by the classloader, no matter what the manifest says.

    A simple workaround is to disable JAR indexing. I'm not sure how to inject an arbitrary Class-Path with indexing enabled.

提交回复
热议问题