JNI and plugins

Questions and answers on developing, deploying and using plugins and JavaBeans

JNI and plugins

Postby mirona » Thu Mar 24, 2005 4:24 pm

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
Mirona Wachlinger Hanze Software
mirona
 
Posts: 7
Joined: Wed Feb 23, 2005 3:51 pm
Location: Timisoara, Romania

Postby IT2Be » Thu Mar 24, 2005 4:33 pm

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.
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby pbakker » Thu Mar 24, 2005 4:54 pm

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
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby mirona » Thu Mar 24, 2005 5:18 pm

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.
Mirona Wachlinger Hanze Software
mirona
 
Posts: 7
Joined: Wed Feb 23, 2005 3:51 pm
Location: Timisoara, Romania

JNI plugin problem

Postby mirona » Thu Mar 24, 2005 7:14 pm

I created the JNLP file and included my native library as a resource, but the error still occurs. It cannot find the library.
Mirona Wachlinger Hanze Software
mirona
 
Posts: 7
Joined: Wed Feb 23, 2005 3:51 pm
Location: Timisoara, Romania

Postby pbakker » Thu Mar 24, 2005 7:37 pm

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

Anyone else?

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby cybersack » Thu Mar 24, 2005 11:32 pm

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

<nativelib href="/plugins/jmf/jmg723.dll" download="eager" version="%%version%%"/>

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
User avatar
cybersack
 
Posts: 302
Joined: Sun Jan 02, 2005 1:17 am

Postby mirona » Fri Mar 25, 2005 10:15 am

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"?>
<jnlp spec="1.0+"
codebase="%%serverURL%%"
href="/servoy-client/plugins/helloPlugin.jar.jnlp">
<information>
<title>Servoy Client Plugins</title>
<vendor>Servoy and Others</vendor>
<offline-allowed/>
</information>
<resources>
<jar href="/plugins/helloPlugin.jar" download="eager" version="%%version%%"/>

//for Mac the library has another name

<nativelib href="/plugins/hello.dll" download="eager" version="%%version%%"/>

</resources>
<component-desc/>
</jnlp>

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?
Mirona Wachlinger Hanze Software
mirona
 
Posts: 7
Joined: Wed Feb 23, 2005 3:51 pm
Location: Timisoara, Romania

Postby jcompagner » Mon Mar 28, 2005 1:35 pm

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.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Postby mirona » Tue Mar 29, 2005 3:43 pm

It works now. Thank you very much.
Mirona Wachlinger Hanze Software
mirona
 
Posts: 7
Joined: Wed Feb 23, 2005 3:51 pm
Location: Timisoara, Romania


Return to Plugins and Beans

Who is online

Users browsing this forum: No registered users and 24 guests