The System.loadLibrary("Something")
will load libSomething.so
or Something.dll
depending on platform. It will search for it in a list of directories (java.library.path
) and will load the first it finds (I think).
I would like to know the full path of the loaded .so
/ .dll
. There is ClassLoader.findLibrary(String libname)
which does exactly what I want, but it is protected
.
A workaround option could be to use System.mapLibraryName(String)
to make platform specific file name from the library name and then to split and iterate through the java.library.path
system property. I suppose it would give the same result as ClassLoader.finLibrary
for most cases, but would it for all cases?
Is there any best practice for this task?