资源路径中找不到jnidispatch

资源路径中找不到jnidispatch

本文介绍了线程“main”中的异常java.lang.UnsatisfiedLinkError:资源路径中找不到jnidispatch(/ com / sun /jna/win32-x86/jnidispatch.dll)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小的测试程序,可以在JBuilder 6调试器中完美运行。当我制作.jar文件并运行它时出现错误

I have a small test program which runs perfectly in the JBuilder 6 debugger. When I make a .jar file and run it I get an error

>java -jar testadll.jar
Start of DLL test
Exception in thread "main" java.lang.UnsatisfiedLinkError: jnidispatch (/com/sun
/jna/win32-x86/jnidispatch.dll) not found in resource path
    at com.sun.jna.Native.loadNativeLibraryFromJar(Native.java:708)
    at com.sun.jna.Native.loadNativeLibrary(Native.java:685)
    at com.sun.jna.Native.<clinit>(Native.java:109)
    at testadll.TestThisDLL$PenniesLib.<clinit>(TestThisDLL.java:24)
    at testadll.TestThisDLL.main(TestThisDLL.java:33)

我搜索了我的驱动器,上面没有jnidispatch.dll。

I have searched my drive and there is no jnidispatch.dll on it.

该计划是

package testadll;

import com.sun.jna.Library;
import com.sun.jna.Native;
//import com.sun.jna.NativeLong;
import com.sun.jna.Platform;
import com.sun.jna.win32.StdCallLibrary;
//import com.sun.jna.*;



public class TestThisDLL {
   public interface PenniesLib extends StdCallLibrary {
    PenniesLib INSTANCE = (PenniesLib) Native.loadLibrary(
            "PenniesLib", PenniesLib.class);
        int a();
    }

  public static void main( String args[] ) {
      System.out.println("Start of DLL test");
      //TestDLL t = new TestDLL();
      //System.out.println("DLL loaded");
      int value = PenniesLib.INSTANCE.a();
      System.out.println("DLL response is " + String.valueOf(value));
  }
}


推荐答案

你显然已经将JNA的类与您自己的jar文件合并,但省略了它的原生支持。确保将原始 jna.jar 中的所有文件(不仅仅是类文件)复制到新目标,并保留其原始路径。

You've apparently merged JNA's classes with your own jar file, but omitted its native support. Ensure that all files from the original jna.jar (not just class files) are copied to the new destination and that their original paths are preserved.

具体来说,你的jar文件必须包括com / sun / jna / win32-x86 / jnidispatch.dll。如果您想包含对其他平台的支持,您还必须包括com / sun / jna / * / jnidispatch

Specifically, your jar file must include com/sun/jna/win32-x86/jnidispatch.dll. If you want to include support for other platforms, you must include com/sun/jna/*/jnidispatch as well.

这篇关于线程“main”中的异常java.lang.UnsatisfiedLinkError:资源路径中找不到jnidispatch(/ com / sun /jna/win32-x86/jnidispatch.dll)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 03:04