Bundle-NativeCode: header in MANIFEST file give "Error: An unexpected error occurred while trying to open file pr.jar"

StackOverflow https://stackoverflow.com/questions/14068000

Pergunta

I was attempting to include natives libraries into a jar file. Though i found how it should be done, there something that is missing. This is the manifest file.

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

As per specification i do use UTF8 encoding and end the file with a new line. Some how loading the jar file

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

In order to replicate the issue, i remove the entire bundle header along with the lib parameters and added an arbitrary header "xyz:" it seems to give the same error, so i conclude, some where my implementation can't identify "Bundle-NativeCode:" Header.

Other information

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)

Library being used is libjitsi.jar

Foi útil?

Solução

I think you should use single spaces instead of tabs or multiple spaces in the Bundle-NativeCode header as the JAR File Specification, Name-Value pairs and Sections specifies:

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

Here is a sample manifest.mf snippet which works for me:

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
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top