9910

单飞

   :: 首页 :: 联系 :: 聚合  :: 管理

System.loadLibary()

The parameter to System.loadLibrary() should be the name of the libary, without path, extension or "lib":

1: System.loadLibrary("payment");

Depending on your platform, this will load libpayment.so or payment.dll.

Although it is not an error to call System.loadLibrary() multiple times, loading the libraries is often done in a static code block:

1: class Test {
2: static {
3: System.loadLibrary("payment");
4: }
5: }

java.library.path



Java searches several directories for this libary file. The directories to search are specified in the property java.library.path. On Linux, this is a copy of the environment variable LD_LIBRARY_PATH. On Windows, it is a copy of the PATH variable.

Although changing the java.library.path has influence on how Java loads its libraries, it has no effect on Windows. When your library depends on other DLLs, these are loaded without taking java.library.path into account. If the library you load needs another library, which can not be found, you get an UnsatisfiedLinkError with the message "Can't find dependent libraries". To solve this, you can load the dependant libraries yourself using multiple calls to System.loadLibrary(), loading all libaries one by one.


就是说假如你要加载的Dll依赖其它dll那你就要自己手工加载在Windows平台。


posted on 2009-04-27 12:10 单飞 阅读(1481) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: