Search code examples
javac++rmi

C++ client for Java RMI? Or any other way to use Java from C++?


We need to use a Java library from C++ code. An idea that I had is that if we could build a C++ client for Java RMI (ideally using some framework or wizard), than we could run the Java lib as a separate server. This seem cleaner than trying to run Java VM within a C++ application.

Alternatively, if you have any other idea on how to use Java from C++, I'd be glad to hear. We work on Linux.

thanks a lot,

David


Solution

  • JNI was the intended solution to the problem of C/C++ to Java integration. It's not difficult.

    Message Queues are better for larger grained interactions, or remote interactions where the message queue is accessible over the network.

    CORBA and RMI were also intended to be network access mechanisms.

    From your description you don't want that. You want to consume a Java library in C++, and to do that, you use JNI.

    How to start the JVM and invoke a Java method, from C++ (JDK doc)