大家帮我看一下,以下是我的代码
public class lzh
{ static String strDll = "UNLHA32"; public native long UnlhaGetVersion(); static
{
System.loadLibrary (strDll);
} public static void main( String[] args )
throws Exception
{
lzh lzhObj = new lzh();
System.out.println(lzhObj.UnlhaGetVersion() + "");
}
}运行出错信息是
C:\project\lzhjava>java lzh
Exception in thread "main" java.lang.UnsatisfiedLinkError: UnlhaGetVersion
at lzh.UnlhaGetVersion(Native Method)
at lzh.main(lzh.java:106)到底是怎么回事?
public class lzh
{ static String strDll = "UNLHA32"; public native long UnlhaGetVersion(); static
{
System.loadLibrary (strDll);
} public static void main( String[] args )
throws Exception
{
lzh lzhObj = new lzh();
System.out.println(lzhObj.UnlhaGetVersion() + "");
}
}运行出错信息是
C:\project\lzhjava>java lzh
Exception in thread "main" java.lang.UnsatisfiedLinkError: UnlhaGetVersion
at lzh.UnlhaGetVersion(Native Method)
at lzh.main(lzh.java:106)到底是怎么回事?
不能这样调的,
应该在lzh的函数里调用dll函数
在动态库UNLHA32.DLL/UNLHA32.LIB中。
我用VC调用都是好的。
你知道java不能与VC用同样动态库,这不是JDirect而是JNI
要经特殊处理,用javah,hehe,lol
java.lang.Object
|
+--java.lang.Throwable
|
+--java.lang.Error
|
+--java.lang.LinkageError
|
+--java.lang.UnsatisfiedLinkError
All Implemented Interfaces:
Serializable --------------------------------------------------------------------------------public class UnsatisfiedLinkError
extends LinkageError
Thrown if the Java Virtual Machine cannot find an appropriate native-language definition of a method declared native.
我没时间查,但跟我说的很象,只是生成的头文件函数名可能不正确,