Where to place .jnilib .so .dll files so they are found at runtime?


I’m trying to use an old library for accessing pressure and tilt on a graphic tablet. It’s these 6 files.

I know the library still works because I can still use it from the Processing IDE.

I placed those files in a libs folder in my Kotlin/Gradle project. IntelliJ code completion works as expected and the program builds fine, but it fails to find the native libraries at run time with this error:

May 27, 2022 3:45:44 PM jpen.provider.NativeLibraryLoader$4 run
INFO: loading JPen 2-150301 JNI library: jpen-2-4-x86_64 ...

May 27, 2022 3:45:44 PM jpen.provider.NativeLibraryLoader$4 logOnFail
INFO: jpen-2-4-x86_64 couldn't be loaded

May 27, 2022 3:45:44 PM jpen.provider.NativeLibraryLoader load
INFO: no suitable JNI library found

I spent a few hours searching how to do this properly but I can’t find an answer. I tried having the libraries inside the build and out folders, I tried things like

    //jni.srcDirs = [...]
    //jniLibs.srcDir '...'


dependencies {

I even tried using inotifywait to figure out where it was trying to load those files from but I failed to do that.

I would very much appreciate some help :slight_smile:

Update: this and this seem to be related, but I’m not sure how to solve it yet.

Update 2: finally I found out that by setting -Djava.library.path=/absolute/path/to/libs in the VM options of the run configuration it does find the library. Later I have to figure out a portable solution but at least I can continue developing.