I’m trying to Bundle a native library with my Eclipse plug-in. When I provide the path of the library with -Djava.library.path, it works perfect.
However, when I add it to the MANIFEST.MF file, it throws an exception that says,
Exception in thread "Thread-9" java.lang.UnsatisfiedLinkError: no XpNamedPipeJni in java.library.path
The code in MANIFEST.MF is
Bundle-NativeCode: lib/XpNamedPipeJni.dll; lib/XpNamedPipeJni_64.dll; osname=Win32; processor=x86; processor=x86-64,
lib/libXpNamedPipeJni.dylib; osname=MacOSX; processor=x86; processor=PowerPC; processor=x86-64
The funny thing is, it works perfectly in Windows with Bundle-NativeCode: lib/XpNamedPipeJni.dll; lib/XpNamedPipeJni_64.dll. The problem comes when I add another line for Mac OS. I also tried Bundle-NativeCode: lib/libXpNamedPipeJni.dylib. Doesn’t work.
I tried all probable permutations of OS/Processor values from OSGi specifications here.
Got it solved. I was using the wrong extension of the library. I changed the extension from
dylibtojniliband it worked. Apparently, the Java VM on OS X seems to require the file extension be.jnilib. Any ideas about the reason behind this?Now the code simply looks like
Bundle-NativeCode: lib/XpNamedPipeJni.dll; osname=Win32; processor=x86,lib/XpNamedPipeJni_64.dll; osname=Win32; processor=x86_64,
lib/libXpNamedPipeJni.jnilib; osname=macosx; processor=x86; processor=x86_64; processor=ppc