Try using this function, which converts jstring to std: string:
void GetJStringContent(JNIEnv *AEnv, jstring AStr, std::string &ARes) { if (!AStr) { ARes.clear(); return; } const char *s = AEnv->GetStringUTFChars(AStr,NULL); ARes=s; AEnv->ReleaseStringUTFChars(AStr,s); }
The solution to your problem:
JNIEXPORT int JNICALL Java_com_ndkfoo_test_GL2JNILib_step2(JNIEnv * env, jobject obj, jstring filePath) { std::string str; GetJStringContent(env,filePath,str); const char *fullPath = str.append("FileName.txt").c_str(); }
source share