Search code examples
javamacosintellij-ideaimportlibraries

Why am I getting java.lang.UnsatisfiedLinkError: no jnisgfplib in java.library.path even though IntelliJ shows no compilation errors, and how to fix?


I set up a Java Application on Intellij to the point where the code compiles and runs. However when invoking one of the native libraries, I get java.lang.UnsatisfiedLinkError: no jnisgfplib in java.library.path, on the line:

    lib = new JSGFPLib();

where the import for JSGFPLib() looks like import SecuGen.FDxSDKPro.jni.*;

Here is what the project structure looks like, notice there are no compilation errors, and that the import I highlighted refers to the directory on the left containing JSGFPLib.

Intellij

Why am I receiving this error and how do I fix it? I am running this on a Mac, which should be able to run Linux Java Apps, since Java is JVM based.


Solution

  • This Java library has native dependencies which are OS specific.

    You need these dependencies (native libraries) to be available in system PATH environment.

    Another option is to specify -Djava.library.path=<dir> property in the VM Options field of the Run/Debug configuration where dir is the directory containing the native libraries for your OS.

    IntelliJ IDEA can also recognize native dependencies automatically when they are added to the module dependencies and will configure -Djava.library.path for you when running.