How C++ can call Java through JNI

(Last Updated On: May 20, 2015)

How C++ can call Java through JNI

So this is how it should be done. This will be useful in Linux for when both the C++/C generated code from Maltba/ Simulink may need to call any front Java generated by Matlab Guide which would be deployed to an executable deployed Java JAR.


Join my FREE newsletter to see how this will be achieved in upcoming trading systems 



On my core i7, the results are the following:

Java called from Java:  14 nanoseconds/iteration
Java called from C++:   23 nanoseconds/iteration
C++ 100% native:         2 nanoseconds/iteration

Each C++ to Java call through JNI has an overhead of 9 to 10 ns. For small functions such as in this benchmark, this overhead is an overkill. So this kind of integration should not be considered for high frequency, low latency function calls. But many JNI applications are about integrating high level Java components or interfaces. In this case, the JNI overhead is negligible compared to the tremendous benefit of the easy integration.


NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Subscribe For Latest Updates

Sign up to best of business news, informed analysis and opinions on what matters to you.
Invalid email address
We promise not to spam you. You can unsubscribe at any time.

Join our Private Chat Server for FREE Trading signals for ETH DOGE ADA

Scroll to Top