Reputation: 387
I am implementing a C++ to Java interface using JNI. I have a C++ function as follows:
static int testhandler(void *arg, uint32_t stream, uint32_t func, const char* name, uint32_t funcgroup, uint32_t source);
When I have to call this in Java using eclipse, I do it as follows:
public void handle(int stream, int func,char name, int group, int token);
But I am not able to read the const char part in Java using Eclipse. Does anybody know what the problem might be? Should I call the method in Java in some other manner?
Upvotes: 0
Views: 330
Reputation: 444
You can't just pass const char*
string through JNI.
Create a jstring
from it using function NewStringUTF
(it is member-function of class JNIEnv
). Then pass it to Java's String
.
Upvotes: 1