大家帮我看一下,以下是我的代码
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)到底是怎么回事?

解决方案 »

  1.   

    public native long UnlhaGetVersion();方法没实现吧
      

  2.   

    如果你想调dll里的函数,
    不能这样调的,
    应该在lzh的函数里调用dll函数
      

  3.   

    当然是实现过的。
    在动态库UNLHA32.DLL/UNLHA32.LIB中。
    我用VC调用都是好的。
      

  4.   

    from sun java sdk api
    你知道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. 
      

  5.   

    运行 javah lzh.class 得到头文件,用这个头文件的函数把你的UnlhaGetVersion包一下,另外文件名最好写  xxx.dll很象JavaProc_UnlhaGetVersion具体记不清了,参考一下java.sun.com Tutorial 里JNI用法
    我没时间查,但跟我说的很象,只是生成的头文件函数名可能不正确,