Calling a java method from c++ in Android

If it’s an object method, you need to pass the object to CallObjectMethod: jobject result = env->CallObjectMethod(obj, messageMe, jstr); What you were doing was the equivalent of jstr.messageMe(). Since your is a void method, you should call: env->CallVoidMethod(obj, messageMe, jstr); If you want to return a result, you need to change your JNI signature (the … Read more

java.lang.UnsatisfiedLinkError no *****.dll in java.library.path

In order for System.loadLibrary() to work, the library (on Windows, a DLL) must be in a directory somewhere on your PATH or on a path listed in the java.library.path system property (so you can launch Java like java -Djava.library.path=/path/to/dir). Additionally, for loadLibrary(), you specify the base name of the library, without the .dll at the … Read more

How to bundle a native library and a JNI library inside a JAR?

It is possible to create a single JAR file with all dependencies including the native JNI libraries for one or more platforms. The basic mechanism is to use System.load(File) to load the library instead of the typical System.loadLibrary(String) which searches the java.library.path system property. This method makes installation much simpler as the user does not … Read more

JNI converting jstring to char *

Here’s a a couple of useful link that I found when I started with JNI http://en.wikipedia.org/wiki/Java_Native_Interface http://download.oracle.com/javase/1.5.0/docs/guide/jni/spec/functions.html concerning your problem you can use this JNIEXPORT void JNICALL Java_ClassName_MethodName(JNIEnv *env, jobject obj, jstring javaString) { const char *nativeString = env->GetStringUTFChars(javaString, 0); // use your string env->ReleaseStringUTFChars(javaString, nativeString); }

Eclipse reported “Failed to load JNI shared library” [duplicate]

First, ensure that your version of Eclipse and JDK match, either both 64-bit or both 32-bit (you can’t mix-and-match 32-bit with 64-bit). Second, the -vm argument in eclipse.ini should point to the java executable. See http://wiki.eclipse.org/Eclipse.ini for examples. If you’re unsure of what version (64-bit or 32-bit) of Eclipse you have installed, you can determine … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)