Search code examples
javac++java-native-interface

How to obtain jchar* from std::string?


I am writing a JNI application. In my C++ code, I have std::string. I need to obtain a jchar * from it to pass to a Java function. How do I do this?


Solution

  • Use env->NewStringUTF(), to create a new java-string from a char*.