關於java的System.load 和 System.loadLibrary


關於兩者的區別(參見http://blog.csdn.net/ring0hx/article/details/3242245)

System.load 參數為庫文件的絕對路徑,可以是任意路徑。
System.loadLibrary方法load的為相對路徑,即在java.library.path定義下的lib文件,文件名會更具不同的系統實現加上不同的前綴、后綴。

例如:System.loadLibrary("foo")

在window中load的是java.library.path路徑下的名字為foo.dll的本地類庫。

參看http://blog.csdn.net/ring0hx/article/details/3242245

在linux中load的是java.library.path路徑下的名字為libfoo.so的本地類庫。

參考http://stackoverflow.com/questions/1010503/how-to-debug-a-java-system-loadlibrary-error-in-linux:I think the issue is with the call to System.loadLibrary(String) and using LD_LIBRARY_PATH. Using loadLibrary("foo") will look in your java.library.path for something named libfoo.so. If nothing named libfoo.so is found you will get this error.

在mac中load的是java.library.path路徑下的名字為libfoo.jnilib/libfoo.dylib的文件

參見https://www.chilkatsoft.com/java-loadLibrary-MacOSX.asp:From developer.apple.com: "JNI libraries are named with the library name used in the System.loadLibrary() method of your Java code, prefixed by lib and suffixed with .jnilib. For example, System.loadLibrary("hello") loads the library named libhello.jnilib. Java HotSpot also recognizes .dylib as a valid JNI library format as of Mac OS X v10.5."




免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM