Rahul Jiresal
Rahul Jiresal

Reputation: 1006

java.lang.UnsatisfiedLinkError: no Library in java.library.path

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.

Upvotes: 2

Views: 8202

Answers (2)

abhijeet104
abhijeet104

Reputation: 636

If your eclipse is not able to load XpNamedPipeJni.dylib (or any filename.dylib), its because eclipse is trying to load it from System by a call System.loadLibrary(fileName) and eclipse is not able to find it from load locations as the file doesn't exist in these locations.

To see from where all eclipse try to load it, add following line in your code:

String locations = System.getProperty("java.library.path");

see all the locations and copy your file into any of these locations,(if location doesn't exist, create it and copy). Restart the eclipse, it will work fine now.

Upvotes: 0

Rahul Jiresal
Rahul Jiresal

Reputation: 1006

Got it solved. I was using the wrong extension of the library. I changed the extension from dylib to jnilib and 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

Upvotes: 3

Related Questions