C / C ++ header for java

Is there a good tool for creating java (+ JNI support, if necessary) from the header file so that you can use the C or C ++ library as is. View reverse Java. The real functionality will be in C / C ++, Java will only be a top pad for certain users.

I'm not an expert at JNI, but as far as I can see, Java is forcing you to do it again. This forces you to have JNI-isms invisibly penetrating C code if you yourself are not writing a conversion layer. And writing a conversion level manually is a waste of time, since all the information is in the header file to start with.

+7
java c ++ c jni
source share
3 answers

For C, you can use JNA . You have to declare the signature functions redundantly in Java, but you don't have to write any glue code. JNA is very easy to use.

For C or C ++, you can use SWIG . SWIG is a bit more difficult to use, but it automatically generates Java wrappers for C ++ classes. I enjoy it.

+3
source share

JNAerator does just that: it reads the C / C ++ / ObjectiveC headers and outputs Java bindings that rely on BridJ (C / C ++), JNA (C only), or Rococoa (ObjectiveC, uses JNA).

+3
source share

It looks like SWIG works with Java: http://www.swig.org/Doc2.0/Java.html

Perhaps this is not exactly what you are looking for, since you need to add SWIG directives ...

+2
source share

All Articles