This question has been asked and answered in many posts like this!
But how can I call from c++ directly ? For this how can I get JNIEnv* and jobject ? Is this possible ?
This question has been asked and answered in many posts like this!
But how can I call from c++ directly ? For this how can I get JNIEnv* and jobject ? Is this possible ?
To get JNIEnv
you can write global JNI_OnLoad
function that will get called during loading of shared library. This function will get JavaVM
pointer as argument. Using it you can get JNIEnv
for current thread (or create new one if there was no JNIEnv
previously).
As to where get jobject - if that is new object you are instantiating, then you use JNIEnv::NewObject
method. Otherwise you need to pass object on which you want to call method from java side to C/C++.