What data types can be passed between c++ and java/java to c++? Also, are the data types equivalent in terms of size?
+2
A:
Using Java Native Interface you can pass just about anything between C++ and Java.
jcopenha
2009-07-04 16:05:52
and what about from java to c++?
Partial
2009-07-04 16:16:18
JNI Supports both directions. It can be tricky and there may be better solutions for you but reading a little about JNI will answer many of your questions and is generally useful knowledge to have.
Duck
2009-07-04 16:27:43
JNA seems to be the popular slightly higher-level Java-native interface at the moment.
Tom Hawtin - tackline
2009-07-04 16:31:34
+1
A:
Also check out CNI if using g++. Don't know if JNI is the same way, but you're basically just using C++ to write within a JVM. That is, you can't pass pure C++ objects to Java. Instead, everything must derive from Object.
keraba
2009-07-04 16:26:53
+1
A:
I prefer Swig myself. It does the JNI wrapping for you allowing calls in any direction you'd like, multithreading, etc. It also works with multiple languages including Java, Python, Perl etc...
Swig is also portable as your C++ code is - I use it myself on Linux and Windows to bridge our C++ code to Java and Python.
Petriborg
2009-07-06 18:00:06