send string from c++ to java
Hello,I send a string (char *) from c++ to java as a inputargument for a method. This works great. But if the string consists of 1-3 character(s) it doesn't work ("Unhandled exception in...(JVM.dll)...Access violation.")Can anybody help?Thanks
[279 byte] By [
XMAS1000a] at [2007-11-26 22:33:53]

# 2
sorry,
I do this:
C++:
char *c="hello";
//char *c = "hi";
jclass cls = env->FindClass(javaClassname);
jmethodID mid = env->GetStaticMethodID(cls, "draw", "(Ljava/lang/String;)[B");
jbyteArray jByteArr = (jbyteArray) env->CallStaticObjectMethod(cls, mid, c); *
Java:
public static byte[] draw(String param){
...
}
If c="hello" the program works perfectly. But if c="hi" (1-3 characters) the prog cancels on *.
# 4
Yeah, I checked specially for you :)You should usejbyteArray jByteArr = ( jbyteArray )env->CallStaticObjectMethod( cls, mid, env->NewStringUTF( c ) );
# 5
I think (jbyteArray) env->CallStaticObjectMethod(cls, mid, c)the error is that c should not be passed as a parameter.env->NewStringUTF( c) will be called before the above calling.