Using native lib with JNI in driver module


I have few question:

it is possible to use a JNI dll native library in Ignition?

I have a jar file that need a JNI/dll to run.
That jar is a library of my ignition driver module.

How can i pack the JNI/dll in the module and use it in Ignition?


It’s possible, but a little on the difficult side.

Have you used JNI before? Will you be the one making the call to System.load() or System.loadLibrary() or are you using a 3rd-party library/jar that does that on its own?

Hi Kevin,

yes, I used before, but not so much.

I’m using System.loadLibrary().

At the moment I found that solution:
a. in the driver I loaded the library: static {System.loadLibrary(“myLib”);}
b. then i copied the myLib.dll in the Ignition lib directory.

The solution works, but it’s not “elegant” :slight_smile:
Have you some suggestion or better solution?

May I ask you another thing not inherent native lib in this post? Or I have to open a new one?


There isn’t exactly an elegant solution to this.

One solution is to do what you do; place the native library in Ignition’s lib folder (which gets added to java.library.path during startup via reflection voodoo) and then use System.loadLibrary().

The other more “portable” solution is to package the native library inside one of your jar files and during module startup copy the native library to a temporary directory and use System.load() on it.