1

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?

Mårten Wikström
  • 11,074
  • 5
  • 47
  • 87
ddss
  • 11
  • 2

2 Answers2

2

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

Mårten Wikström
  • 11,074
  • 5
  • 47
  • 87
  • It is easy to generate JNI code with SWIG for calling C from Java, I have done that already. But my problem is the other direction, calling Java methods from C functions. So this doesn't solve my problem. – ddss Apr 21 '13 at 17:14
  • 1
    @ddss I've updated my answer with another link that I hope you'll find useful. – Mårten Wikström Apr 21 '13 at 19:03
  • Thank you for your help, but this is c++, and my code is pure c. – ddss Apr 21 '13 at 21:04
0

The only JNI wrappers of this type I'm aware of are Jace and JunC++ion, both of which are C++ based so don't fit your needs.

GooseSerbus
  • 1,249
  • 11
  • 15