How do you create a MANIFEST.MF that's available when you're testing and running from a jar in production?

前端 未结 9 1041
失恋的感觉
失恋的感觉 2020-12-28 16:28

I\'ve spent far too much time trying to figure this out. This should be the simplest thing and everyone who distributes Java applications in jars must have to deal with it.

9条回答
  •  萌比男神i
    2020-12-28 17:21

    You want to use this:

    Enumeration resources = Thread.currentThread().getContextClassLoader().getResources("META-INF/MANIFEST.MF");
    

    You can parse the URL to figure out WHICH jar the manifest if from and then read the URL via getInputStream() to parse the manifest.

提交回复
热议问题