Manifest file generated inside meta-inf is missing classpath reference

房东的猫 提交于 2021-02-11 18:10:20

问题


I am trying to generate jar file for the eclipse project using eclipse export jar feature. I am making absolute reference to a library in my manifest file

Manifest-Version: 1.0
Sealed: true
Main-Class: org.ad.TestMain
Class-Path: D:/demojar/commons-lang3-3.8.1.jar

I also tried with Class-Path: file:///D:/demojar/commons-lang3-3.8.1.jar and relative path like lib/commons-lang3-3.8.1.jar

My project structure is shown here

I export the jar as shown below making reference to the manifest file

When I unpack my jar, manifest file generated under meta-inf folder does not contain classpath reference.The code complains about library not existing. How can I resolve this issue?

My main issue here is why classpath generated in the manifest file under meta-inf does not show the classpath referenced?


回答1:


Remove the D: from the classpath and make the path relative to where your main jar is located

i.e)

folder/
folder/YourJar.jar
folder/lib/commons-lang3-3.8.1.jar

The manifest should be

Main-Class: org.ad.TestMain
Class-Path: lib/commons-lang3-3.8.1.jar


来源:https://stackoverflow.com/questions/59145327/manifest-file-generated-inside-meta-inf-is-missing-classpath-reference

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!