I forgot that I need to declare these methods too. I thought they are inbuilt in JNI. Just need to add the following lines of code -
static char* g_RetStr;
static int g_RetStrLen = 16384;
struct JavaString
{
jstring _Ref;
JavaString ( const char *Buffer )
{
JNIEnv *env = s3eEdkJNIGetEnv();
_Ref = env->NewStringUTF ( Buffer );
}
JavaString ( jstring Ref )
{
_Ref = Ref;
}
~JavaString()
{
JNIEnv *env = s3eEdkJNIGetEnv();
env->DeleteLocalRef ( _Ref );
}
operator jstring()
{
return _Ref;
}
};
const char* getCString(jstring str)
{
JNIEnv* env = s3eEdkJNIGetEnv();
if (!str)
return NULL;
jboolean free;
const char* res = env->GetStringUTFChars(str, &free);
g_RetStrLen = strlen(res) + 1;
g_RetStr = (char *)s3eEdkReallocOS(g_RetStr, g_RetStrLen);
strcpy(g_RetStr, res);
env->ReleaseStringUTFChars(str, res);
return g_RetStr;
}
//In Init
g_RetStr = (char*)s3eEdkMallocOS(g_RetStrLen);