我尝试了多种方法从正确的jar中访问清单。 我的问题是它似乎在读取它所涉及的第一个jar文件,而不是我的课程。 这是我最新的尝试我无法在我的java代码中访问正确的MANIFEST.MF文件
InputStream is = Test.class.getResourceAsStream("/META-INF/MANIFEST.MF");
try {
if (is == null) {
System.out.println("null no input stream");
} else {
Manifest manifest = new Manifest(is);
Attributes attributes = manifest.getMainAttributes();
v = attributes.getValue("Test");
System.out.println("Test="+v);
v = attributes.getValue("Created-by");
System.out.println("By="+v);
}
} catch (IOException e) {
System.out.println("error");
} finally {
if (is != null) {
is.close();
}
}
而这些结果
测试= NULL 通过= 1.6.0_18(Sun微系统公司)
我我想要的MANIFEST.MF有值为测试,所以我知道这是读错文件
有谁知道我可以如何指定包含清单文件的jar?
不幸的是仍然给我同样的不正确的结果...... 测试= NULL 通过= 1.6.0_18(Sun微系统公司) – AttikAttak 2013-02-27 16:37:17
他已经读文件,否则输出会一直:_NULL没有输入流_ – OscarRyz 2013-02-27 16:40:56