Hi,
You can see a sample in the sources of JNative here : http://jnative.cvs.sourceforge.net/jnative/JNativeCpp/org_xvolks_jnative_JNative.cpp?revision=1.9&view=markup
at line 458. The JNU_SetFieldByName is defined here :
http://jnative.cvs.sourceforge.net/jnative/JNativeCpp/jni_util.c?revision=1.1&view=markup
at line 1108.
--Marc (http://jnative.sf.net)
Thanx for answer but unfortunately it didnt solve my problem.
Let me tell what i am trying do ..
i define a native function in Java whit under code
public static native int get_text();
after i compile a header file with javah , i define a string in C++
string myString="abcdefghi";
then i wrote
JNIEXPORT jint JNICALL Java_dll_get_text
Java_firstJNI_getLine(JNIEnv *env)
//Here, what must i write for send myString to JAVA ?
After this Now. what must i write to send myString variable in JAVA ?
i couldnt find anything. when i get any integer value , i dont see any problem but if i try to get string, i coudnt :((
Hi,
So your function should be private static native String get_text();
(It's often a good idea to make native methods private since when you change signatures you generally have to change java wrapper methods only).
I know nothing about C++ strings but I'm pretty sure that you can convert it to char*, so
do :
char* szMyString = myString.toChar*();
Then return from native with JNU_NewStringPlatform(env, szMyString)
(see my 1st answer for JNU_NewStringPlatform() description).
--Marc (http://jnative.sf.net)