Search code examples
javanode.jsjna

Load Java JNA native library in Node


I'm running a JNA compiled native library through [node-java] wrapper for Node.js 1

The library is Hunspell JNA that wraps the hunspell spelling library.

In my simplest test

     var instance=java.callStaticMethodSync("dk.dren.hunspell.Hunspell","getInstance");
     console.log( instance );

what happens is that node seems to hang when trying to load the native library from the lib path:

hsl = (HunspellLibrary)Native.loadLibrary(libFile, HunspellLibrary.class);

in this method, so it seems to be a JNA problem when calling the loadLibrary method.

The library is there, and I have also tried the second option of that method to copy in a temporary folder and load from there, so I can see

Loading temp lib: /var/folders/_b/szqwdfn979n4fdg7f2j875_r0000gn/T/jna5370593161365499003.libhunspell-darwin-x86-64.dylib

that it is there.


Solution

  • What's the data it's receiving and is it receiving any?

    getInstance(String libDir) The instance of the HunspellManager, looks for the native lib in the directory specified.

    from man(1) hunspell: The default dictionary depends on the locale settings. The following environment variables are searched: LC_ALL, LC_MESSAGES, and LANG. If none are set then the default personal dictionary is $HOME/.hunspell_default.

    Hope it helps.