关于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."



转载于:https://www.cnblogs.com/serendipity/articles/5303639.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值