java - JNI : Exception in thread "AWT-EventQueue-0" java. lang.UnsatisfiedLinkError 错误

标签 java c++ java-native-interface

我正在使用 java 开发应用程序。我使用 JNI 层C 层 通信 java。但是在调用 native 时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代码

函数声明

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;

   }

我浏览了很多链接,但没有找到解决方案。请帮我找出这个异常的解决方案

最佳答案

自从使用 javah 生成 .h 文件后,您已经更改了包名称。重新生成它并相应地调整您的 .c 文件。请注意,包名称编码在 C 函数名称中。

关于java - JNI : Exception in thread "AWT-EventQueue-0" java. lang.UnsatisfiedLinkError 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21480981/

相关文章:

java - HashMap 如何识别内部数组中的哪些位置包含元素?

Java问题

c++ - openmp中的并行for循环

java - 如何在 JNI 中访问从 C++ 返回 java.lang.String 的 Java 方法的返回值?

java - 应用程序 C++/Java 依赖

java - 如何使用故障转移初始化 activeMQ 代理

java - 对字段的 Lambda 引用

c++ - 为什么 boost::signals2::signal<T>::connect 需要复制构造函数?

java - 如何从 C++ 调用 Java 方法

android - 从 java 传递给 jni 的参数返回奇怪的值