The API you are using uses loadLibrary (String) . It seems you cannot successfully preempt (make it succeed) by first invoking a more explicit load (String) .
So you must specify the path in java.library.path .
This System property is set at the beginning of the JVM life cycle and is not modified by standard tools.
Thus, the usual solution would be to pass the appropriate java.library.path when starting the JVM.
Alternatively, you can learn hacks to change this property after starting the JVM using reflection. I have not tried any of them.
For example, see here :
System.setProperty( "java.library.path", "/path/to/libs" ); Field fieldSysPath = ClassLoader.class.getDeclaredField( "sys_paths" ); fieldSysPath.setAccessible( true ); fieldSysPath.set( null, null );
By the way, I would recommend providing your own path to an existing path, rather than replacing it.
source share