JNI : Exception in thread “AWT-EventQueue-0” java.lang.UnsatisfiedLinkError

匿名 (未验证) 提交于 2019-12-03 00:58:01

问题:

I am working on application in java.I have use JNI layer to communicate java with the C layer.But while calling the native function in java , the application gives following exception,

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 code

Function declaration

public native float Ivb_GetGain(int gain); 

Function call

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

JNI Code

JNIEXPORT jfloat JNICALL   Java_org_jni_DeviceCommunicationController_Ivb_1GetGain  (JNIEnv *, jobject, jint gain)    {    jfloat val = 0;   val = Syntac_GlobalGain(gain);   return val;     } 

I gone through many links but didn't find the solution.Please help me to find out solution on this ecxeption

回答1:

You've changed the package name since you generated the .h file with javah. Regenerate it and adjust your .c file accordingly. Note that the package name is encoded in the C function name.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!