How to convert char* to jcharArray in JNI
<p>How can I convert char* to jcharArray in JNI?</p>

<p>What code do I have to put in // TODO comment part?</p>

<pre><code>JNIEXPORT jcharArray JNICALL Java_finger_FingerPrintJNI_GetVer(JNIEnv *env, jobject thisObj){
    char* version = getText(); // Returns char* data type
    int version_len = strlen(version);

    jcharArray j_version_array = env-&gt;NewCharArray(version_len + 1);

    // TODO Convert char* to jcharArray

    return jcharArray;
}
</code></pre>

<p>Add ======================================================================</p>

<p>As Gearon suggested, when I put the below code an error is raised. </p>

<pre><code>jchar* jVersion = (jchar*)version;
env-&gt;SetCharArrayRegion(jcharArray, 0, version_len, jVersion);
</code></pre>

<p>Following is the error message. </p>

<pre><code>JNIEnv_::SetCharArrayRegion(jcharArray,jsize,jsize,const jchar *)': cannot convert argument 1 from 'jchar *' to 'jcharArray'
sample.cpp(26): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
</code></pre>