views:

984

answers:

4

Hi,

i creat a plugin wich includes the folder structure

  • src
  • native/so/libsystemcommand.so
  • META-INF/MANIFEST.MF

The manifest include the command

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Commands Plug-in
Bundle-SymbolicName: de.system.commands;singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: de.system.commands.CommandsPlugin
Bundle-Localization: plugin
Bundle-NativeCode: native/so/libsystemcommand.so; osname = Linux; processor = x86
Require-Bundle: org.eclipse.core.runtime,
 org.apache.commons.logging
Eclipse-AutoStart: true
Export-Package: de.system.commands,
 de.system.commands.jni,
 de.system.commands.utils
Bundle-ClassPath: .

The build.properties looks like

source.. = src/
output.. = bin/
bin.includes = META-INF/,\
               .,\
               native/

in the start methode of my Activator class i call

System.loadLibrary("systemcommand");

At runtime the library is not found and a UnsatisfiedLinkError is thrown.

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

Do i have to set more attributes in the plugin? Do i have to unzip some informations on the target platform?

EDIT:

java.library.path=/opt/jdk/j2re1.4.2_16/lib/i386/client:/opt/jdk/j2re1.4.2_16/lib/i386:/opt/jdk/j2re1.4.2_16/../lib/i386::/opt/dsa/lib:/opt/dsa/lib
A: 

The lib has to be in your filesystem (not in an archive file). Then you can either use the linux environment variable LD_LIBRARY_PATH pointing to the lib or define the property java.library.path

flolo
i expect, that the plugin would do this fopr me, because on Windows platforms this is working without additional library path.
Markus Lausberg
@flolo - you are mistaken; the Eclipse framework supports loading native libraries from plugin bundles (JAR files).
McDowell
+1  A: 

I wonder if the library needs to be specified without the lib prefix? E.g.,

System.loadLibrary("systemcommand");

Since that is how the library would be passed on a gcc link line.

Thanks, but this is also not working.
Markus Lausberg
http://mindprod.com/jgloss/runerrormessages.html#UNSATISFIEDLINKERROR suggests that the opposite (add the .so suffix) is the right answer.
you were right!!! the library has to load withou starting "lib"
Markus Lausberg
+1  A: 

In a plugin fragment for linux, I use:

Bundle-NativeCode: librptlc.so; osname = linux; processor=x86

And in the main plugin I use:

if (OS.equals(Platform.OS_LINUX)) {
    System.loadLibrary("rptlc");
}

This should work within one plugin too.

I seem to remember having some problems with libraries in a sub folder in the jar, but I'm not sure why this would be the case. I just stuck to having the libraries in the root of a plugin fragment instead, which works for me.

You could also try getting the file system path of the library (not sure if that's easy) and loading it using:

libraryPath = "C:\eclipse\bundles\123\librptlc.so";
System.load(libraryPath);
Mike Houston
+1  A: 

I think i found the solution.

We only build the plugin which was not working and copy it to the destination platform directory. After this we start the application as wtach the log files whether the library was foud or not.

What we miss, was to delete the configurations folder. The new plugin was not unzipp and the library was not existing in the configurations directory.

Im sorry and thank you for your answers.

Markus Lausberg
Easy to make mistake, hard to see consequences. Same thing happened to me....
Mario Ortegón