Using DLL in an Eclipse plugin [message #329827] |
Mon, 07 July 2008 13:52 |
Eclipse User |
|
|
|
Originally posted by: e.daoura.hotmail.com
Hello everybody,
I have a dll library, written in C, as an interface to communicate with Hardware.
I am trying to create a plugin that access to the hardware through the dll file as an interface. This plugin will be used in a RCP application later.
To access to the dll I am using in my Java code the JNI (the java native interface).
In my stand-alone Java Swing application I put the DLL in my classes dir and it works well. But when I now try to port the application to a plugin that is used by an RCP application, the RCP software doesn't seem to find the DLL. I get an UnsatisfiedLinkException all the time.
I have tried to put the /lib/matrix32.dll in the build.properties and in the manifest file (Bundle-NativeCode: /lib/matrix32.dll; osname=win32; processor=x86) but it didn't work.
How can I set the properties of my plugin to let the dll accessible from an RCP application through the plugin? (It will be great if it is possible to put it in the exported plug-In jar file).
Regards
Thanks
Emil
|
|
|
|
|
Re: Using DLL in an Eclipse plugin [message #329845 is a reply to message #329841] |
Tue, 08 July 2008 12:12 |
Eclipse User |
|
|
|
Originally posted by: automatic.javalobby.org
If your plugin is the *.jar the answer is yes
I successfully use Jogl from an extra plugin which is
not extracted and bundled as a *.jar (from the product config.).
|
|
|
Re: Using DLL in an Eclipse plugin [message #329879 is a reply to message #329845] |
Wed, 09 July 2008 07:28 |
Eclipse User |
|
|
|
Originally posted by: automatic.javalobby.org
Yes my plugin is a jar. And it still doesn't work.
It is look like:
1- "myplugin" is a jar file that includes the dll file.
2- "myplugin" acts as a library that adapts the use of the dll functions to my own necessity.
3- The packages of "myplugin" are exported to be accessible from outside.
4- I copied the "Myplugin" in the target folder that is used by my rcp application
5- On the side of "myrcp application" I could import the packages from the myplugin without problems.
6- Running the rcp-application gives me the following message at the call of the native functions of the dll (included in "myplugin"):
UnsatisfiedLinkError message [com.robotmallorca.key.Matrix.Init_MatrixAPI()S]
Exception in thread "Thread-3" java.lang.UnsatisfiedLinkError: com.robotmallorca.key.Matrix.Init_MatrixAPI()S
at com.robotmallorca.key.Matrix.Init_MatrixAPI(Native Method)
at com.robotmallorca.key.Key.Matrix_Test(Key.java:68)
at com.robotmallorca.kernel.CLoggerSenderThread.run(CLoggerSend erThread.java:127)
com.robotmallorca.key is myplugin
Matrix is a class of myplugin
Init_MatrixAPI() is a native function (defined in the dll file)
com.robotmallorca.kernel is a package of my rcp-application
Please, I need help !!
|
|
|
Re: Using DLL in an Eclipse plugin [message #329884 is a reply to message #329879] |
Wed, 09 July 2008 11:50 |
Eclipse User |
|
|
|
Originally posted by: automatic.javalobby.org
Hm... i can't understand the fourth step
<i>4- I copied the "Myplugin" in the target folder that is used by my rcp application</i>
As far as i understand you have a RCP application
and an dependent JNI "Myplugin".
Now in your main plugin the JNI plugin is noted in the "Dependencies" tab.
You JNI plugin has to have this structure as an example
YourPlugin/
- x.jar <-your communication jars
- xx.jar
- src <-your communication classes
- META-INF
- build.properties
- your.dll
- your2.dll
In the "Runtime" tab of your JNI plugin all necessary packages are exported and furthermore in the "Classpath" section of the runtime tab the jni-communication *.jars (if available) are registered.
Normally this should work then.
|
|
|
Re: Using DLL in an Eclipse plugin [message #329886 is a reply to message #329884] |
Wed, 09 July 2008 13:26 |
Eclipse User |
|
|
|
Originally posted by: automatic.javalobby.org
First, thanks for the reply
I have two different projects:
1- RCP Plugin, I will call it RCP_Plugin
2- A dependent JNI Plugin I will call him "JNI_Plugin" (directly associated to a my.dll)
With the fourth step I mean: I export the " JNI_Plugin " to JNI_Plugin.jar . Then I copy the exported JNI_Plugin.jar file into the location folder that is set in "Preferences->Plug-in Development->Target Platform-> Location" of my RCP_Plugin application.
JNI dependet JNI_Plugin/
- bin/
- src/
- lib/my.dll
- META-INF/MANIFEST.MF
- build.properties
- .classpath
- .project
- .build.properties
In the "Runtime" tab of JNI_Plugin all necessary packages are exported but the "Classpath" section of the runtime tab is empty.
I export the JNI_Plugin into JNI_Plugin.jar and I copy it into the "target" folder that is used by the RCP_Plugin
RCP_Plugin /
- ../target/JNI_Plugin.jar
- ../target/org.eclipse.core.runtime_3.3.100.v20070530.jar
- ../target/ org.eclipse.ui_3.3.0.I20070614-0800.jar
- ../target/org.eclipse.*.jar (a copy of all needed eclipse plugins)
- src/
- bin/
- META-INF/MANIFEST.MF
- .classpath
- .project
- build.properties
- plugin.xml
In the "Runtime" tab of RCP_Plugin there are no packages exported and the "Classpath" section of the runtime tab is empty too.
Need I put the JNI_Plugin.jar in the Classpath section of the runtime tab of the RCP_Plugin ? I only put it in the dependencies tab in Required Plug-ins section.
It doesnt work.:-(
Thanks again
|
|
|
Re: Using DLL in an Eclipse plugin [message #329890 is a reply to message #329886] |
Wed, 09 July 2008 14:51 |
Eclipse User |
|
|
|
Originally posted by: automatic.javalobby.org
Hello Emil,
I use a different way of archieving this but many ways are leading to Rome.
I recognized that you put the *.dll in a subfolder.
Put the *.dll directly in the top folder of the JNIPlugin
(not in a subfolder like lib/your.dll) maybe then it works
If you use the default workspace of Eclipse:
In your RCP plugin register your JNI plugin which are both present
in your eclipse workspace:
workspace/
YourRCPPlugin
YourJNIPlugin
Register the JNIPlugin in the RCP plugin
under Dependencies
Export all necessary classes in the JNIPlugin for your RCP plugin.
Create a new Run configuration and in the plugins tab
add the required plugins which are necessary for your RCP.
Then simply test your RCP with with the plugin.
That should work, too.
For the export you can create a feature which let you decide
to pack or unpack your JNI plugin.
|
|
|
Re: Using DLL in an Eclipse plugin [message #329905 is a reply to message #329890] |
Thu, 10 July 2008 09:57 |
Eclipse User |
|
|
|
Originally posted by: automatic.javalobby.org
Hello Marcel,
Thanks for the reply :-)
I moved the my.dll to the root of the JNIPlugin, like you said.
I read too in the link you gave me that native code should be at the root level of the plugin. Furthermore I changed the following, instead of doing System.loadLibrary("my.dll"), I defined Bundle-NativeCode: my.dll; osname=win32; processor=x86
Even more, I have heard that the PDE runtime only consults the entries in the .classpath when running/debugging inside Eclipse, and it's only when I try to export the product that the Manifest.MF will is consulted. For that reason I exported the MyRCPPlugin to a product. In the plugins tab of the product configuration I added all required plugins including JNIPlugin.jar.
But unfortunately the MyRCPPlugin can find the native codes of my.dll.
I don't know, what can I do more!!!
|
|
|
Re: Using DLL in an Eclipse plugin [message #329955 is a reply to message #329905] |
Fri, 11 July 2008 10:57 |
Eclipse User |
|
|
|
Originally posted by: automatic.javalobby.org
Have you selected all files in the build tab of your plugin?
Maybe you can make a crosscheck
Options are:
Put the *.dll and your access code directly in your
RCP to see if it works there.
Try to run another project with a *.dll (Jogl for example which works definetely).
These are dumb suggestions but maybe help in the diagnosis
|
|
|
Re: Using DLL in an Eclipse plugin [message #329956 is a reply to message #329955] |
Fri, 11 July 2008 11:37 |
Eclipse User |
|
|
|
Originally posted by: automatic.javalobby.org
Hi Marcel,
I already tried to put the my.dll in the RCP root. It doesn't work. I will try it with the Jogl, how you mentioned.
But now I installed the Software "Dependency Walker" to see if the my.dll depends on other dll files.
The result was:
my.dll depends on KERNEL32.dll, USER32.dll, WINSPOOL.DRV and ADVAPI32.dll. I think those dll files are from windows.
Do you know if my problem is related to the above mentioned dependency of the dlls ? If yes, what do you think what can I do to resolve the java.lang.UnsatisfiedLinkError.
thanks again
|
|
|
Re: Using DLL in an Eclipse plugin [message #330047 is a reply to message #329956] |
Mon, 14 July 2008 08:47 |
Eclipse User |
|
|
|
Originally posted by: automatic.javalobby.org
Hi Marcel,
there is something new :-)
I tried to put the *.dll in the MyRCP_Plugin and I tried to access to the "my.dll" directly without using a JNIPlugin. And it doesn't work too.
I think that the problem is in:
Bundle-NativeCode: matrix32.dll; osname=winvista; processor=x86
in the Manifest file.
How can i tell the RCP where my.dll is?
|
|
|
Powered by
FUDForum. Page generated in 0.04919 seconds