Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Bundle-NativeCode dlls
Bundle-NativeCode dlls [message #101127] Mon, 05 November 2007 22:16 Go to next message
Jaime is currently offline JaimeFriend
Messages: 56
Registered: July 2009
Member
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
Re: Bundle-NativeCode dlls [message #101140 is a reply to message #101127] Tue, 06 November 2007 02:02 Go to previous messageGo to next message
Eclipse UserFriend
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 #101159 is a reply to message #101140] Tue, 06 November 2007 09:36 Go to previous messageGo to next message
Jaime is currently offline JaimeFriend
Messages: 56
Registered: July 2009
Member
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
Re: Bundle-NativeCode dlls [message #101174 is a reply to message #101159] Tue, 06 November 2007 14:31 Go to previous messageGo to next message
Eclipse UserFriend
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 #101289 is a reply to message #101159] Thu, 08 November 2007 13:57 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------010503000201030008020403
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

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.
>

Jaime, please paste your Bundle-NativeCode header so we can have a look.
The native code should get extracted from your bundle jar into the
configuration cache of the framework.

If you are able to look at the file system of your PDE you should
find a configuration/ directory where the config.ini is located.
This directory should have an org.eclipse.osgi directory. This
directory contains cached native files (among other things).
You should be able to find your extracted libraries under there
in a directory that looks like this

org.eclipse.osgi/bundles/<bundle id>/<bundle gen>/<path to lib>

If you do not see your file then something must have gone wrong
with extracting the library. You could try enabling the loader
trace/debug options, but this tends to spew out very verbose messages.
But it will print out debug info on native code lookups. To enable the
trace option for the loader use the attached .options file with the
-debug command line argument. It has been a while since I've worked on
a PDA. But if I remember correctly the System.out is not always easy to
capture or view.

You may also try the eRCP newsgroup/mailing list, they specialize in
running Equinox on PDAs.

HTH.

Tom.

--------------010503000201030008020403
Content-Type: text/plain;
name=".options"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename=".options"

b3JnLmVjbGlwc2Uub3NnaS9kZWJ1Zy9sb2FkZXI9dHJ1ZQ==
--------------010503000201030008020403--
Re: Bundle-NativeCode dlls [message #101344 is a reply to message #101289] Fri, 09 November 2007 11:31 Go to previous messageGo to next message
Jaime is currently offline JaimeFriend
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 Go to previous message
Thomas Watson is currently offline Thomas WatsonFriend
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
>
Previous Topic:Http Sessions
Next Topic:Open Source Software Research
Goto Forum:
  


Current Time: Wed Apr 24 22:51:47 GMT 2024

Powered by FUDForum. Page generated in 0.03321 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top