Home:ALL Converter>Calling a Java Method from the native code using jni

Calling a Java Method from the native code using jni

Ask Time:2015-01-20T17:53:33         Author:şirket için

Json Formatter

I am new at using JNI. I successfully write a few programs that call native methods written in c.

Now I need my java code to be called by the native code side after it is initialized. Is it possible? Until now, I tried some kind of polling techniques. That is, I check native code parameters from my java code periodically, but if there is a way that native code can send some kind of interrupt it could be more efficient. Is it possible? Or can you suggest a better way than polling?

Note: When I search for "Call Java Functions from C Using JNI" all the answers I get is like

http://www.codeproject.com/Articles/22881/How-to-Call-Java-Functions-from-C-Using-JNI

JNI Call java method from c program

Those examples is not an answer for my situation. Because my main program is in java, and what I ask is that: Can the native functions(written in c) that I call from java code call some other java functions under certain circumstances? Is it possible to manage this without using a polling technique like I mentioned above?

Author:şirket için,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/28042285/calling-a-java-method-from-the-native-code-using-jni
yy