通过获取sun.arch.data.model可判断是32还是64的JAVA

将32或者64位的DLL放不同的目录,实现自适应调用DLL

  Properties props = System.getProperties();
  String bits=String.valueOf(props.get("sun.arch.data.model"));  

  String path = IMyNative.class.getResource("/").getPath() + "dll"+bits;
  System.out.println(path);
  // path=path.substring(1,path.length()).replace("/", "\\");
  File file = new File(path + "/MyNative.dll");
  System.out.println(path);
  System.load(path + "/MyNative.dll");
  NativeLibrary.addSearchPath("MyNative.dll", path);

 

JNA需要以下包:

jna.jar   platform.jar

下载地址:/Files/wasp520/lib.rar

相关文章:

  • 2021-09-06
  • 2022-12-23
  • 2022-12-23
  • 2021-06-07
  • 2022-01-02
  • 2021-09-14
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
  • 2021-12-30
  • 2022-12-23
  • 2022-12-23
  • 2021-09-02
相关资源
相似解决方案