简体   繁体   中英

Is it possible to call java method from C code with SWIG generated JNI?

I am trying to use SWIG to generate my JNI. I already have JNI code that is working, but it is hand written and it is getting more and more complicated and difficult to maintain.

Some of my functions in C are called from Java, and then they call some methods in Java (probably it is not a good idea, but it is working for now)...

I am wondering if it is possible for SWIG to generate that kind of JNI code?

Yes it should be possible.

The following languages are also supported in swig-1.3.6 onwards: Java JDK 1.1 and newer.

Quoted from http://www.swig.org/compat.html

More info here:

UPDATE : For more info on calling Java from C++ have a look at: http://www.swig.org/Doc1.3/Java.html#java_directors

我知道的这种类型的JNI唯一包装器是JaceJunC ++ ion ,它们都是基于C ++的,因此不符合您的需求。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM