IPC between Java and C applications

前端 未结 4 1338
傲寒
傲寒 2021-01-20 08:33

I have 2 applications, one written in C and the other in Java, that suppose to run on the same machine. What is the best way to implement an IPC between them?

best m

4条回答
  •  醉梦人生
    2021-01-20 09:03

    I've found that the simplest approach is to exec the native program from java, and then communicate via the process input and output streams. This only works for ASCII communication though, which in most cases is fine. This approach works across platforms. If the applications are launched independently of eachother, then files or sockets are both cross-platform approaches and will work with binary data if desired.

    There's always JNI or JNA, but these are typically best suited to a tight couplin between java and native code.

提交回复
热议问题