sigar-amd64-winnt.dll … can't reference it or bundle it with .jar

好久不见. 提交于 2019-12-04 14:53:19

For me it was always the best to modify the way how Java loads the library.

Usually you call System.loadLibrary("mylib"); which searches the library on the library path.

IMHO it is much better loading the library using it's absolute path. This allows you to implement a custom search logic in your program:

// Extends the name to mylib.so or mylib.dll
mylibname = System.mapLibraryName("mylib"); 

// Load the library via its absolute path
System.load(new File(path, mylibname).getAbsolutePath());

Note that each library can only be loaded once, therefore if you load the library as shown above, calls of System.loadLibrary("mylib"); afterwards will be ignored as the library is already loaded.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!