Topic: 有关JNI的问题(急)

  Print this page

1.有关JNI的问题(急) Copy to clipboard
Posted by: jefention
Posted on: 2004-12-22 17:20

小弟在做JNI时遇到问题,源代码如下:
package test;
public class Test {
public Test() {
}
static{
System.loadLibrary(“Test”);
}

public static native void set(int value);
public static native int get();

public static void main(String[] arg){
System.out.println("test");
get();
}
}

用javah编译生成Test.h
用VC生成动态库,一切都照着资料做,可是执行程序时会出现如下异常:
java.lang.UnsatisfiedLinkError: get

at test.Test.get(Native Method)

at test.Test.main(Test.java:29)

test

Exception in thread "main"

实在不解,Test.dll文件已经找到(Test.dll文件被copy到winnt\system32中),可是说里面的方法有问题,在网上看了好多文章,都没有提到这个问题,请哪位经验人士帮忙解答,谢谢!

2.Re:有关JNI的问题(急) [Re: jefention] Copy to clipboard
Posted by: sc
Posted on: 2004-12-22 18:04

运行时,没有指定java.library.path吧?Big Smile

3.Re:有关JNI的问题(急) [Re: sc] Copy to clipboard
Posted by: jefention
Posted on: 2004-12-22 18:29

指定path了。将Test.dll文件放到winnt\system32中就行了。现在可以肯定的是Test.dll文件是肯定找到了,只是调用里面的方法抛出了异常。

4.Re:有关JNI的问题(急) [Re: jefention] Copy to clipboard
Posted by: tool
Posted on: 2004-12-31 07:34

你的问题可能出在VC那边。用VC的Depends工具(DEPENDS.EXE)看看Test.dll是否有如下两个export函数:
_Java_test_Test_set@12
_Java_test_Test_get@8


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923