Call C ++ code from Java (GCJ)

I am trying to call C ++ from Java using GCJ using CNI, so far I can call Java code from C ++. How can I call C ++ from Java using CNI?

+7
java c ++ g ++ cross-language gcj
source share
3 answers

I am producing a pcent answer somewhat to read the GCJ / CNI Docs .

I believe the key is to understand the concept of the whole “CI Class C ++”.

  • Creating a CI CNI class is explained in this page .
  • You can call Java code from the CNI C ++ class (assuming you have created the header files) - this is what you are already doing (calling Java from C ++).
  • The key point is that C ++ CNI methods can be called from Java (because these classes have a set of restrictions for their compatibility with Java). And since the CNI class is only a C ++ class (special kind), you can also link it to other libraries in the same way you would any C ++ class.

Most of the documentation describes how Java conventions translate in the CI C ++ class.

+4
source share

Try reading the GCJ / CNI Docs

0
source share

I am not a good Java programmer, but I am familiar with C # / C ++ interop. The best solution for calling from native C ++ managed managed C # was to use Callbacks . I think this applies to JNI

Try reading: http://www.tidytutorials.com/2009/07/java-native-interface-jni-example-using.html

-one
source share

All Articles