JNI and plugins

Hello,

I work at a Servoy runtime application and I implemented a plugin for it.
In the plugin I have a class which calls native functions using JNI.
I run the application on Mac.
If I use my plugin in Servoy the “java.lang.UnsatisfiedLinkError” occurs, because the jni library (for example libmyapp.jnilib) cannot be found.
I put this library in the plugins and lib folder of Servoy, but the error still occurs.
To see what is wrong I made a test.jar with a class that uses this library and run it from a console with:
“java -jar test.jar” and it works fine only if the jni library is located in the same folder.
If it is on a different path I must use java -jar -Djava.library.path=/…
test.jar to tell java where to find the library.
Can somebody tell me how can I set the java.library.path in Servoy?
Maybe this way it will find my library.

Thank you

Hai, don’t know what app you use to develop your plugin so this will be a generic answer.

You have an issue with the classpath from within your plugin not Servoy. So you should include the classpath to the library in your plugin.

When doing so there is no issue anymore. If I were you I would drop the library in the plugins directory (or create a specific folder under the plugings dir) and point to that location. That should do the trick.

If your Servoy plugin needs additional jars, you should create a JNLP file for it, in which you specify the libraries.

See the Scheduler plugin for examples.

Paul

I wrote the class-path to my jni library in the MANIFEST.MF file, but I have the same error.

I don’t need additional jars, I use only a jni dynamic library created with gcc. Is this JNLP file really necessary?

Thank you for your help.

I created the JNLP file and included my native library as a resource, but the error still occurs. It cannot find the library.

mmm, I’m sorry, this is how far my knowledge goes.

Anyone else?

Paul

In my resources section of my media-manager jnlp i have :

Libs are found just fine.
The point, maybe, is that the path is relative to ${servoy.home}; so, if your native lib exists in another directory tree, this could be the problem.

My $0.02 :)

julian

Hello,

I used the JNLP file on Mac and on Windows and I put the native library in the plugins folder. It doesn’t work. The error message is java.lang.UnsatisfiedLinkError: no hello in java.library.path

<?xml version="1.0" encoding="utf-8"?>


Servoy Client Plugins Servoy and Others

//for Mac the library has another name

If I run the plugin from the console or Eclipse everything is fine.
I don’t understand what I’m doing wrong. Why it works for you?

as far as i read here you are working with servoy runtime/developer where you have these problems?

Then jnlp doesn’t do anything (with youre jnlp examples the servoy client should work)

If the standalone does work in the startup dir. Then it should also work for you by dropping the dll just in the /servoy/ dir

Or else just specify it in the sh file. Specify the java.library.path in the “java -jar servoy_developer.jar” line.

It works now. Thank you very much.