【发布时间】:2014-11-07 19:40:53
【问题描述】:
我在 jar 文件中有以下清单:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.9.3
Created-By: 1.7.0_67-b01 (Oracle Corporation)
Main-Class: tld.project.Example
Name: tld/project
Specification-Title: Example
Specification-Version: 1.0
Specification-Vendor: Me
Implementation-Title: tld.project
Implementation-Version: 20140913
Implementation-Vendor: Me
我在运行时使用以下内容从清单中读取一些属性:
// Try and load the Jar manifest as a resource stream.
InputStream manInputStream = Example.class.getResourceAsStream("/META-INF/MANIFEST.MF");
if (manInputStream != null) {
// Try and extract a version string from the Manifest.
Manifest manifest = new Manifest(manInputStream);
Attributes attributes = manifest.getAttributes("tld/project");
为什么上面的代码将属性设置为空,但只在 OS X 上? (1.7.51) 如果我检查 manifest.getEntries().size() 它也返回零,但同样,这在 Windows 和 Linux 上按预期工作。有什么想法吗?
【问题讨论】:
-
我认为最可能的解释是,由于某种原因,清单不是您认为的 Mac 上的内容。我想不出任何其他方式。