meta-inf内部生成的清单文件缺少类路径引用 [英] Manifest file generated inside meta-inf is missing classpath reference
问题描述
我正在尝试使用eclipse导出jar功能为eclipse项目生成jar文件.我正在对清单文件中的库进行绝对引用
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
我也尝试过使用Class-Path: file:///D:/demojar/commons-lang3-3.8.1.jar
和相对路径,例如 lib/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
解压缩jar时,在meta-inf文件夹下生成的清单文件不包含类路径引用.代码抱怨库不存在.我该如何解决这个问题?
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?
我的主要问题是为什么在meta-inf下的清单文件中生成的类路径未显示引用的类路径?
My main issue here is why classpath generated in the manifest file under meta-inf does not show the classpath referenced?
推荐答案
从类路径中删除 D:
,并相对于主jar所在的路径进行构建
Remove the D:
from the classpath and make the path relative to where your main jar is located
即)
folder/
folder/YourJar.jar
folder/lib/commons-lang3-3.8.1.jar
清单应该是
Main-Class: org.ad.TestMain
Class-Path: lib/commons-lang3-3.8.1.jar
这篇关于meta-inf内部生成的清单文件缺少类路径引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!