现情况如下:
我现在又一个DLL,我想用java的JNI或者jacob调用里面的方法,假设现在这个DLL文件名叫TESTDLL.dll,里面有两个函数:第一个是method1,里面传两个参数是字符串型的,这个函数返回一个数字。
第二个方法是method2,里面传两个参数,一个是数字,一个是字符串,这个函数返回空。
现在我已经在静态方法里加载了,可是报错,报没有依赖类库,求指点!
static{
System.loadLibary("TESTDLL");
}下面就不会写了。。也求指点!希望大家不吝指教
我现在又一个DLL,我想用java的JNI或者jacob调用里面的方法,假设现在这个DLL文件名叫TESTDLL.dll,里面有两个函数:第一个是method1,里面传两个参数是字符串型的,这个函数返回一个数字。
第二个方法是method2,里面传两个参数,一个是数字,一个是字符串,这个函数返回空。
现在我已经在静态方法里加载了,可是报错,报没有依赖类库,求指点!
static{
System.loadLibary("TESTDLL");
}下面就不会写了。。也求指点!希望大家不吝指教
解决方案 »
- Java异常处理中出现特殊情况解析
- java创建内存文件
- 如何取得相对路径
- 如何让TextField中焦点不能移动?
- 高分请教一个Socket编程服务器端的问题!
- 关于synchronized的用法
- [600G] Java全套视频教程及部分项目教程免费下载
- 各位老大:使用JTextField组件添加DocumentListener监听内容改变时,如何动态的获得它当前的录入值?
- applet连接数据库,写了一个policy文件,用appletviewer可以browse,但是如何在ie和nc中带那个policy文件?请各位帮忙一下...
- java连接oralce成功,但无法查询:table or view does not exist
- swing做的软件中,持久化层数据库一般怎么进行管理?
- JSplitPane设置成纵向之后,如何固定下面的大小?
JNI加载库的原理是解释程序利用dlopen接口(或者与其类似的接口)动态链接和加载so/dll,并调用其中的方法.dlopen的描述信息:dlopen()
The function dlopen() loads the dynamic library file named by the null-
terminated string filename and returns an opaque "handle" for the
dynamic library. If filename is NULL, then the returned handle is for
the main program. If filename contains a slash ("/"), then it is
interpreted as a (relative or absolute) pathname. Otherwise, the
dynamic linker searches for the library as follows (see ld.so(8) for
further details): o (ELF only) If the executable file for the calling program contains
a DT_RPATH tag, and does not contain a DT_RUNPATH tag, then the
directories listed in the DT_RPATH tag are searched. o If, at the time that the program was started, the environment vari‐
able LD_LIBRARY_PATH was defined to contain a colon-separated list
of directories, then these are searched. (As a security measure
this variable is ignored for set-user-ID and set-group-ID pro‐
grams.) o (ELF only) If the executable file for the calling program contains
a DT_RUNPATH tag, then the directories listed in that tag are
searched. o The cache file /etc/ld.so.cache (maintained by ldconfig(8)) is
checked to see whether it contains an entry for filename. o The directories /lib and /usr/lib are searched (in that order). If the library has dependencies on other shared libraries, then these
are also automatically loaded by the dynamic linker using the same
rules. (This process may occur recursively, if those libraries in turn
have dependencies, and so on.)
能看到具体是什么类库吗,知道的话,就把缺失的放入系统的类库路径比如System32中
//System.load("E:\\TESTDLL.dll"); /* 文件放在任意目录下,括号内为dll的路径,dll名需要加上.dll */是不是因为你的dll文件的路径不对?