Home » Eclipse Projects » Equinox » Bundle-NativeCode dlls
|
Re: Bundle-NativeCode dlls [message #101140 is a reply to message #101127] |
Tue, 06 November 2007 02:02 |
Eclipse User |
|
|
|
Originally posted by: lifesting.gmail.com
Jaime wrote:
> Hi,
>
> I've bundled one dll with the "Bundle-NativeCode" in the Manifest file. I've
> deployed this bundle in a PDA with IBM J9 CDC, but it looks that it doesn't
> work as I expected.
>
> I need to extract the native library and especify it in the
> "java.library.path" system property. Is it the normal behaviour? Do you have
> some experience about it?
>
> Thank you in advance,
> Jaime
>
>
Did you forget packaging the DLL in bundle?
I built a bundle which includes several dll files, just setting the
property "Bundle-NativeCode" in file manifest.mf, then packaging them in
bundle jar. You can't set the system property "java.library.path" when
OSGi runtime is running, in fact the property points to the location
where a bundle file was installed, it can't be changed!
You also don't omit to reference the dll library in your Java file, for
example, System.loadLibrary(xxxxx)
The best example is the bundle org.eclipse.swt.XXXXXX.jar in every
distributed Eclipse SDK. you can look into it for details.
|
|
| |
Re: Bundle-NativeCode dlls [message #101174 is a reply to message #101159] |
Tue, 06 November 2007 14:31 |
Eclipse User |
|
|
|
Originally posted by: lifesting.gmail.com
Jaime wrote:
> Hi David,
>
> Thanks for your answer, but I didn't forget to include the dll or the
> "System.loadLibrary". I set the "java.library.path" before starting Equinox.
> It was the only way to make it work.
>
> Did you test it in Windows? Because it looks like the problem is in the PDA
> but not in Windows.
>
> BR,
> Jorge
> "David BY Chan" <lifesting@gmail.com> escribió en el mensaje
> news:fgoi04$3aq$1@build.eclipse.org...
>> Jaime wrote:
>>> Hi,
>>>
>>> I've bundled one dll with the "Bundle-NativeCode" in the Manifest file.
>>> I've deployed this bundle in a PDA with IBM J9 CDC, but it looks that it
>>> doesn't work as I expected.
>>>
>>> I need to extract the native library and especify it in the
>>> "java.library.path" system property. Is it the normal behaviour? Do you
>>> have some experience about it?
>>>
>>> Thank you in advance,
>>> Jaime
>> Did you forget packaging the DLL in bundle?
>>
>> I built a bundle which includes several dll files, just setting the
>> property "Bundle-NativeCode" in file manifest.mf, then packaging them in
>> bundle jar. You can't set the system property "java.library.path" when
>> OSGi runtime is running, in fact the property points to the location where
>> a bundle file was installed, it can't be changed!
>>
>> You also don't omit to reference the dll library in your Java file, for
>> example, System.loadLibrary(xxxxx)
>>
>> The best example is the bundle org.eclipse.swt.XXXXXX.jar in every
>> distributed Eclipse SDK. you can look into it for details.
>
>
yeah, the application I produced is running on Windows. PDA is strange
to me because I hadn't used anyone before:).
|
|
| |
Re: Bundle-NativeCode dlls [message #101344 is a reply to message #101289] |
Fri, 09 November 2007 11:31 |
Jaime Messages: 56 Registered: July 2009 |
Member |
|
|
Hi Tom,
Thanks for your help. I tried in eRCP some days ago but I couldn't solve the
problem.
I thought that it was not possible to load native libraries in J9, but it's
not true. I created a "helloWorld" bundle that only loaded my native
library, and it worked. Then I changed my OSGi application and write the
loadLibrary in the Activator, and it also worked. Unfortunately, it doesn't
work if the loadLibrary is executed in the suitable place of the application
:(
I'm sure that it's not a problem of the manifest file because it works in
other circumstance (as I've said before). But find it here, perhaps is
useful for someone in the future:
Bundle-NativeCode: native/libraryXP.dll;osname=WindowsXP;processor=x86,
native/libraryCE.dll;osname="Windows CE";processor=ARM
Both libraries (one for XP and the other for CE) are bundled in the "native"
directory.
I said in the eRCP forum that I abandoned this problem, at least for the
moment. However, you've provided some very useful hints:
- To check the configuration directory. I've checked that, when the
loadLibrary works, there's a native directory with this dll file. However,
when the loadLibrary fails, this native directory is not available. This
directory is:
...\configuration\org.eclipse.osgi\bundles\5\1\.cp\native
where 5 is the bundle identifier (I don't know what's the meaning of 1)
- The debugging. It could be very helpful. I've tried your suggestion but
it appears in the console, but not in the log file (stored in the
configuration directory). It's impossible to read the output (too fast) and
only the last lines appear (the buffer of the J9 console is limited). Is
there any way to store this console output in a log file? In other case,
this hint is not so useful in J2ME environments.
Thanks in advance,
Jaime
"Tom Watson" <tjwatson@us.ibm.com> escribi
|
|
|
Re: Bundle-NativeCode dlls [message #101407 is a reply to message #101344] |
Fri, 09 November 2007 23:01 |
Thomas Watson Messages: 503 Registered: July 2009 |
Senior Member |
|
|
Jaime wrote:
> Hi Tom,
>
> Thanks for your help. I tried in eRCP some days ago but I couldn't solve the
> problem.
>
> I thought that it was not possible to load native libraries in J9, but it's
> not true. I created a "helloWorld" bundle that only loaded my native
> library, and it worked. Then I changed my OSGi application and write the
> loadLibrary in the Activator, and it also worked. Unfortunately, it doesn't
> work if the loadLibrary is executed in the suitable place of the application
> :(
Strange. So when you call loadLibrary from the activator it works? Do
you happen to launch with a security manager enabled? The only thing I
can think of is that there may be a bug where the native code extraction
is not protected properly with a doPriv call in one case but not in the
other. Somehow maybe from your activator the call is protected with a
proper doPriv?
>
> I'm sure that it's not a problem of the manifest file because it works in
> other circumstance (as I've said before). But find it here, perhaps is
> useful for someone in the future:
>
> Bundle-NativeCode: native/libraryXP.dll;osname=WindowsXP;processor=x86,
> native/libraryCE.dll;osname="Windows CE";processor=ARM
>
> Both libraries (one for XP and the other for CE) are bundled in the "native"
> directory.
>
> I said in the eRCP forum that I abandoned this problem, at least for the
> moment. However, you've provided some very useful hints:
> - To check the configuration directory. I've checked that, when the
> loadLibrary works, there's a native directory with this dll file. However,
> when the loadLibrary fails, this native directory is not available. This
> directory is:
> ...\configuration\org.eclipse.osgi\bundles\5\1\.cp\native
> where 5 is the bundle identifier (I don't know what's the meaning of 1)
> - The debugging. It could be very helpful. I've tried your suggestion but
> it appears in the console, but not in the log file (stored in the
> configuration directory). It's impossible to read the output (too fast) and
> only the last lines appear (the buffer of the J9 console is limited). Is
> there any way to store this console output in a log file? In other case,
> this hint is not so useful in J2ME environments.
Is it possible to pipe the output on the PDA to a file? On Windows it
would be something like this
java -jar some.jar > out.txt
Not sure if you can do that on the PDE or not.
>
> Thanks in advance,
> Jaime
>
|
|
|
Goto Forum:
Current Time: Fri Sep 20 06:20:28 GMT 2024
Powered by FUDForum. Page generated in 0.03395 seconds
|