I am trying to convert Jstring to native Go string, but unable to convert that. Actually I have created JNI file in Java, by using of JNI file I have created header file in c++ (.h file). After that I am using header file in Go for calling JNI Method. I am able to call the Go DLL through Java code but I get an empty string in Go.
//Go Code:
//''''''''''''''''''''''''''''''
//export Java_CallingMethodjni_
func Java_CallingMethodjni_(env *C.JNIEnv, clazz C.jclass, certtype
C.jstring, filepath C.jstring) C.jstring {
fmt.Println("CallingJava_CallingMethodjni_jni_CallingMethodjni...")
fmt.Print(string(filepath))
// unable to read file path
var js string = string(filepath)
}
//'''''''''''''''''''''''''''''''''''''''''''''''''''''''
//C++ header :
// '''''''''''''''''''''''''''''''''''''''
#include <jni.h>
#ifndef _Included_CallingMethodjni_
#define _Included_CallingMethodjni_
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT jstring JNICALL Java_CallingMethodjni_
(JNIEnv *env, jobject obj, jstring javaString, jstring javaString1);
#ifdef __cplusplus
}
#endif
#endif