I define a Java class from C with DefineClass (), but I get UnsatisfiedLinkError

I define a java class from C with a JNI call to DefineClass (), and then register my own callbacks for class methods that are native. The class has two static methods, both of which are native. I use RegisterNatives () to register my own functions. Both calls are successful.

But when I reference these native methods from my Java code, I get java.lang.UnsatisfiedLinkError myPackage.myClass.myMethod (I) V

But I know that DefineClass returned a class object for myPackage.myClass, and I know that myMethod (I) V was registered as a method in this class.

I get this failure the same way it is going to execute main () - where is the call to my own method (for now for testing).

As a test, I tried calling DefineClass twice on a single JNIEnv to find out what happened. I get a double class definition error. I also tried calling FindClass () after defining it, and JNIEnv returns a reference to a specific class.

This way, I definitely create the class dynamically, but it fails when I try to reference its methods.

Any ideas? All input is evaluated.

Platform: Windows, 32-bit code on a 64-bit version of XP.

+5
source share
1 answer

, DefineClass() . ( - Java), . . , .

- , . , , , 4 8- . . ( ), .

, , 3 . , , .

? . ( C), Java SDK. .

+2

All Articles