A jbyteArray is actually a very good way to pass a Java string through JNI. This allows you to easily convert a string to the character set and encoding needed by the libraries and files / devices that you use on the C ++ side.
Make sure you understand the β Absolute Minimum Every Software Developer Absolutely, positively needs to know about Unicode and character sets (no excuses!) β
Java String uses Unicode character set and UTF-16 encoding (with platform dependent byte order).
String.getBytes () is converted to the "default platform encoding". Thus, he makes an assumption about the character set and the encoding you need, and what to do with characters that are not in the target character set. You can use other Java overloads of String.getBytes or Charset methods if you want to explicitly control these things.
When deciding which character set and encoding to use, consider that Unicode has been used for a couple of decades as the main string type in Java, .NET, VB, ...; in the compiler source files for Java, ...; usually in www. Of course, you may be limited to what you want to interact with.
Now it seems that the problem you are facing is either that the target character set does not contain the characters that your Java string has, and the substitution is used, or the console you use does not display them properly.
The console (or any application with a user interface), obviously, should choose a font with which to display characters. Typical fonts usually do not support the million code points available in Unicode. You can change the configuration of your console (or use another). For example, on Windows you can use cmd.exe or ps (Windows PowerShell). You can change the font in windows Cmd.exe and use chcp to change the character set.
UPDATE:
As @ main-- points out, if you use a function that expects the terminator to be added to the string, you should provide it, usually by copying the array, since the JVM retains ownership of the array. This is the actual reason for the behavior in this case. But all of the above also matters.