JNI : 线程 "AWT-EventQueue-0 "中出现异常 java.lang.UnsatisfiedLinkError

 2023-01-20    315  

问题描述

我正在java中的应用程序.我使用 jni layer 与 java 与 c layer ..但在调用本地的同时Java功能,该应用程序给出以下例外,

Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: org.jni.DeviceCommunicationController.Ivb_GetGain(I)F
at org.jni.DeviceCommunicationController.Ivb_GetGain(Native Method)
at org.jni.GetGain.<init>(GetGain.java:11)
at org.mainWindow.AppWindow$3.stateChanged(AppWindow.java:281)
at javax.swing.JSlider.fireStateChanged(Unknown Source)
at javax.swing.JSlider$ModelListener.stateChanged(Unknown Source)
at javax.swing.DefaultBoundedRangeModel.fireStateChanged(Unknown Source)
at javax.swing.DefaultBoundedRangeModel.setRangeProperties(Unknown Source)
at javax.swing.DefaultBoundedRangeModel.setValueIsAdjusting(Unknown Source)
at javax.swing.JSlider.setValueIsAdjusting(Unknown Source)
at javax.swing.plaf.basic.BasicSliderUI$TrackListener.mouseReleased(Unknown Source)
at javax.swing.plaf.synth.SynthSliderUI$SynthTrackListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Java代码

JNI : 线程 &quot;AWT-EventQueue-0 &quot;中出现异常 java.lang.UnsatisfiedLinkError

功能声明

public native float Ivb_GetGain(int gain);

功能调用

// int gain = 13;
new DeviceCommunicationController().Ivb_GetGain(gain);   // here i get the exception

JNI代码

JNIEXPORT jfloat JNICALL   Java_org_jni_DeviceCommunicationController_Ivb_1GetGain
 (JNIEnv *, jobject, jint gain)
   {

  jfloat val = 0;
  val = Syntac_GlobalGain(gain);
  return val;

   }

我经历了许多链接,但没有找到解决方案.请帮助我找出有关此Ecxection的解决方案

推荐答案

您已经更改了包名称,因为您使用Javah生成了.H文件.再生它并相应地调整.c文件.请注意,软件包名称是在C函数名称中编码的.

以上所述是小编给大家介绍的JNI : 线程 "AWT-EventQueue-0 "中出现异常 java.lang.UnsatisfiedLinkError,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对77isp云服务器技术网的支持!

原文链接:https://77isp.com/post/26110.html

=========================================

https://77isp.com/ 为 “云服务器技术网” 唯一官方服务平台,请勿相信其他任何渠道。