Reputation: 817
I have a C++/Qt application. I want to talk to it using Java. I know I can create TCP server/client. What other options do I have?
The problem is that I created TCP server inside the application and it does not work. But works fine when run in standalone mode. So looking for alternatives ways of communication between C++ and Java.
Upvotes: 2
Views: 1125
Reputation: 53205
I have a C++/Qt application. I want to talk to it using Java. I know I can create TCP server/client. What other options do I have?
Basically, what you are looking for is IPC that is supported by both languages properly. You can find several solutions out there:
Java and C++ socket communication.. Obviously, QtNetwork and the socket classes in there could be your friend for this on the Qt side.
http://www.velocityreviews.com/forums/t279534-communication-between-a-c-and-java-program.html
Java Native Interface. You would be able to call C/C++ methods from Java and vice versa, although this would be probably one of the slowest solutions.
Shared Memory (SHM) (Here, QSharedMemory could aid you on the Qt side).
Dbus (Here, QtDbus could aid you on the Qt side). This is not necessarily cross-platform a solution, however.
I would personally suggest to use raw socket based low-level solution with the Qt API. This is the most reliable in my opinion, and well-proven technology behind. There is Qt Jambi with Qt style API for the java side, and then of course in C++, you will get the QtNetwork API. This would at least provide you some consistency throughout the projects.
Upvotes: 3