This topic is now archived and is closed to further replies.

Java JNI Error

This topic is 5013 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Howzit I''ve written a Java file and C++ file just as it is in the tutorial and I still get an error. java.lang.UnsatisfiedLinkError: runNative at Native.runNative(Native Method) at TestNative.main( Exception in thread "main" It''s finding the dll but not the method. I''m using Dev-C++ to make the dll. Heres the code: Java class: public class Native { public native void runNative(); } header file: /* DO NOT EDIT THIS FILE - it is machine generated */ #include <jni.h> /* Header for class Native */ #ifndef _Included_Native #define _Included_Native #ifdef __cplusplus extern "C" { #endif /* * Class: Native * Method: runNative * Signature: ()V */ JNIEXPORT void JNICALL Java_Native_runNative (JNIEnv *, jobject); #ifdef __cplusplus } #endif #endif C++ file: #include <jni.h> #include "Native.h" #include <stdio.h> JNIEXPORT void JNICALL Java_Native_runNative(JNIEnv* env, jobject thiObj) { printf("Native method executed successfully!!!"); } implementing class: public class TestNative { static { System.out.println("Loading..."); System.loadLibrary("native"); System.out.println("Loaded!"); } public static void main(String[] ar) { Native nat = new Native(); nat.runNative(); } } Shot

Share this post

Link to post
Share on other sites