Wednesday, 16 October 2013

Native Library in Eclipse RCP

Native Library in Eclipse RCP Plug-in

Adding native library in eclipse RCP is little-bit bit tricky part. Mainly native library has extensions like .so or .dll . There are multiple ways to define this kind of libraries to the eclipse RCP plug-in. (Follow steps one by one anyone of them will work.)

Here we take one example :
Suppose you have following directory structure

     --- nativeFile.jar

1. Adding library to the project

For adding library to the project , right click on Project name -> select "Properties..." -> then go to "Java Build Path"
Add nativeFile.jar from External jar button.
Expand nativeFile.jar and double click on "native library location"
enter the path "<dirPath>/NativeLibraryDirectory/"

Set following environment before starting the Eclipse.

setenv LD_LIBRARY_PATH <dirPath>/NativeLibraryDirectory/:$LD_LIBRARY_PATH

3. Using -Djava.library.path


4. Updating Menifiest (Bundle-Nativecode)

Add following line in MANIFEST.MF

Bundle-NativeCode: /libs/yourlib.dll; /libs/someotherlib.dll; osname=win32; processor=x86

Anyone of above method will work so try it one by one. The do following steps.

Before Using the libray in the code mention following lines