JNI中的UnsatisfiedLinkError [英] UnsatisfiedLinkError in JNI
问题描述
我想使用JNI从Java调用C#代码
JNI调用C ++库,然后C ++调用C#
我的代码在这里
I want to call C# code from Java using JNI
JNI call C++ Library,then C++ call C#
My Code is here
package javacsharptest;
public class JavaCSharpTest {
public native void display();
static {
System.loadLibrary("JavaCSharpTest");
}
public static void main (String[] args) {
new JavaCSharpTest().display();
}
}
我收到此错误,
线程主"中的异常java.lang.UnsatisfiedLinkError:javacsharptest.JavaCSharpTest.display()V
在javacsharptest.JavaCSharpTest.display(本机方法)
在javacsharptest.JavaCSharpTest.main(JavaCSharpTest.java:18)
我已经将JavaCSharpTest.dll放入C:\ Windows \ System32
请帮助我:confused:
I got this error,
Exception in thread "main" java.lang.UnsatisfiedLinkError: javacsharptest.JavaCSharpTest.display()V
at javacsharptest.JavaCSharpTest.display(Native Method)
at javacsharptest.JavaCSharpTest.main(JavaCSharpTest.java:18)
I''ve already put JavaCSharpTest.dll into C:\Windows\System32
Please Help me:confused:
推荐答案
看看这个:
Java本机接口:程序员指南和规范 [
Take a look at this:
Java Native Interface: Programmer''s Guide and Specification[^]
You need proper stdcall function export entries in your dll
Regards
Espen Harlinn
使用此命令时:
"System.loadLibrary(" JavaCSharpTest);"
loadLibrary
那么dll文件必须位于,x:\ Program Files \ Java \ jdk1.6.0_20 \ bin
否则,您可以使用System.load("x:\ JavaCSharpTest.dll");
https://sites.google.com/site/stark9000/java-native-interface-helloworld
when you you use this command :
"System.loadLibrary("JavaCSharpTest");"
loadLibrary
then the dll file need to be in , x:\Program Files\Java\jdk1.6.0_20\bin
else you can use , System.load("x:\JavaCSharpTest.dll");
https://sites.google.com/site/stark9000/java-native-interface-helloworld
检查是否正确定义了C库中的函数定义(通常通过运行 javah [
Check that your function definition in the C library has been correctly defined (usually by running the javah[^] command against your Java class file.
这篇关于JNI中的UnsatisfiedLinkError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!