0

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 ?

Community
  • 1
  • 1
madan kandula
  • 460
  • 5
  • 22

2 Answers2

1

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++.

Mārtiņš Možeiko
  • 12,733
  • 2
  • 45
  • 45
0

You need to read the Invocation section of the JNI Specification.

user207421
  • 305,947
  • 44
  • 307
  • 483