Click here to Skip to main content
15,566,065 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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();
    }
}


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:
Posted
Updated 2-Jan-11 19:15pm
v2

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
 
Share this answer
 
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
 
Share this answer
 
v2
Check that your function definition in the C library has been correctly defined (usually by running the javah[^] command against your Java class file.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900