converting jstring to char in c
843829Dec 3 2002 — edited Dec 3 2002I'm trying to convert a jstring to const char (a pointer), but I keep getting an exception.
is there some kind of defenition I'm missing????
here's part of the code:
jmethodID methID;
jstring jstr;
const char *str;
/* Get a reference to obj2 class */
jclass cls = (*env)->GetObjectClass (env, obj2);
if (cls == NULL){
return; /*return in case the object couldn't be found */
}
methID = (*env)->GetMethodID (env, cls, "getPgmId", "()Ljava/lang/String;");
jstr = (jstring) (*env) -> CallCharMethod(env, obj2, methID);
if (jstr == NULL){
printf (" \nthe result String is null \n");
fflush(stdout);
return;
}
str = (char)(*env)->GetStringUTFChars (env, jstr, 0);