I have a Java application that uses a shared C++ library via JNI. I am targeting Windows, Mac, and Linux platforms.
I have just started using jpackage to create an installer, and this works fine for the Windows platform (I have not tried Mac yet). My shared library is located in the same folder as my executable jar.
On Linux (Zorin), the created installer runs and installs my app, but the app fails to load the native library when run.
I have tried using the jpackage --java-options '-Djava.library.path=.," but to no avail.
Running the Java app (on Linux) from the command line with the -Djava.library.path=. option works fine.
When targeting the Windows platform, the jpackage-created installer appears to work correctly simply by ensuring that the shareable library is located in the same folder as the executable jar.
Has anyone seen a jpackage example for creating a Linux app that uses a shared library?
Edited to add:
I just discovered that the linux deb installer installs the app into /opt/<lowercaseappname>
with the executable jar and library located within lib/app
.
Consequently, I have found that specifying the jpackage command line option --java-options '-Djava.library.path=/opt/<lowercaseappname>/lib/app'
to give the absolute path for the shared library does work - but this does not feel like the right solution!