This is more of an opinion than an answer, but given that you have a choice, I highly recommend not using JNI and, rather, communicating between your C ++ application and the Java virtual machine using a different mechanism, such as Sockets or web services . If you get it right, the JNI solution will be much faster than any of these alternatives, but if performance is not critical, then my JNI experience is that it is best avoided.
As EJP (+1) correctly points out, if you do not properly manage your JNI Java objects, very bad things will happen - including the VM just dying. I also found that JNI code is very difficult to verify.
source share