Best practice to package java and native library

Hi,

short question on the following use case:
I would like to package and distribute a Java application, that needs a native (C++) library as well.
The build process is not on focus, but packaging and mainly setting of java.library.path.

Setup (for Linux):
Std-gradle project using application plugin. The native library is included in the distribution by:

distributions {
     main {
         contents {
             into ('lib') {
               from ("farAway/libNativeVersion.so");  
             }
         }
     }
 }

This results in a tarball, that included jars, start script as well as native library (in the lib folder).

Challenge/ Question:
By distributing the tarball, the start script could easily point to a relative directory (=> ‘lib’) in order to define -Djava.library.path, which is needed to locate the native library. Unfortunately, this does only work, if the startscript is started in a predefined location.
Some people propose to ‘hack’ the startscript, in order to use $APP_HOME (Hm…).
(Furthermore variable replacement in the startscript seems to be changed with 7.2)

Is there any guidance to configure a project to find native libraries for a Java application?

Thank you in advance for any comment/ example.
-Axel
#native