How to call C++ from Java?

user970500 picture user970500 · Sep 29, 2011 · Viewed 54.3k times · Source

I wanted to call a C++ method from Java. I read about JNI, but I am not getting how to get all the library files and where I should keep it in order to run the program from command line.

Is there any way to call a C++ method from Eclipse itself, because I am using it to run Java classes.

Answer

Michael Anderson picture Michael Anderson · Sep 29, 2011

While I've used JNI-C++ bridging in the past (only a little though) - it can be a bit ugly. You might want to consider using SWIG to help you generate all the messy boiler plate code.