Bundle-NativeCode:MANIFEST文件中的标题给出“错误:尝试打开文件pr.jar时发生意外错误”

时间:2012-12-28 10:18:38

标签: java java-native-interface osgi jna jmf

我试图将本机库包含到jar文件中。虽然我发现它应该如何完成,但仍有一些缺失。这是清单文件。

Manifest-Version: 1.0
Class-Path: .
Main-Class: ListMediaDevices

Name: library
URL: http://jspeex.sourceforge.net/
Library-Version: 0.9.7
Library-Name: JSpeex

Name: build
Build-Date: 10/05/2010 18:59
Built-With: Linux 2.6.32-21-generic amd64
Built-By: damencho

Bundle-NativeCode:
    lib/jnawtrenderer.dll;
    lib/jndirectshow.dll;
    lib/jnffmpeg.dll;
    lib/jng722.dll;
    lib/jnopus.dll;
    lib/jnportaudio.dll;
    lib/jnscreencapture.dll;
    lib/jnspeex.dll;
    lib/jnwincoreaudio.dll;
    osname=Win32;processor=x86

根据规范,我确实使用UTF8编码并以新行结束文件。一些如何加载jar文件

java -jar pr.jar give "Error: An unexpected error occurred while trying to open file"

为了复制问题,我删除了整个bundle头以及lib参数并添加了一个任意标题“xyz:”它似乎给出了同样的错误,所以我得出结论,有些我的实现无法识别“Bundle-NativeCode:”标题。

其他信息

java -version
java version "1.7.0_07"
Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode)

正在使用的库是libjitsi.jar

1 个答案:

答案 0 :(得分:5)

我认为您应该在Bundle-NativeCode标题中使用单个空格而不是制表符或多个空格,而JAR File Specification, Name-Value pairs and Sections指定:

header:            name : value
name:              alphanum *headerchar
value:             SPACE *otherchar newline *continuation
continuation:      SPACE *otherchar newline

这是一个适用于我的示例manifest.mf片段:

Created-By: Apache Maven Bundle Plugin
Bundle-NativeCode: aaaaaaaaaaa.dll, bbbbbbbbbbb.dll, cccccccccc.dll, d
 ddddddddddddddd.dll, eeeeeeeeee.dll, ffffffff.dll, ggggggggggggggg.dl
 l, hhhhhhhhhhhhhhhhhh.dll, iiiiii.dll