大华sdk使用时遇到“java.lang.NoClassDefFoundError: com/sun/jna/Callback”的解决方法

问题

在使用大华 sdk 进行开发时,打包jar文件后,运行报错:

Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/jna/Callback
        at org.farpig.App.main(App.java:20)
Caused by: java.lang.ClassNotFoundException: com.sun.jna.Callback
        at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
        ... 1 more

或者报错:

Exception in thread "main" java.lang.NoSuchMethodError: com.sun.jna.Platform.getOSType()I
        at org.farpig.dahua.lib.Utils.getOsPrefix(Utils.java:15)
        at org.farpig.dahua.lib.Utils.getLoadLibrary(Utils.java:75)
        at org.farpig.dahua.lib.NetSDKLib.<clinit>(NetSDKLib.java:17)
        at org.farpig.dahua.service.InitServer.<clinit>(InitServer.java:17)
        at org.farpig.App.main(App.java:20)

解决方法

添加如下依赖:

<dependency>
      <groupId>net.java.dev.jna</groupId>
      <artifactId>jna</artifactId>
      <version>4.1.0</version>
    </dependency>
posted @ 2020-10-21 17:13  会飞的小黑鱼  阅读(3287)  评论(0编辑  收藏  举报