What is the best way to pass information from java to c++?

后端 未结 8 1755
太阳男子
太阳男子 2021-02-07 04:59

I have a java application I need to pass some info to a C++ program. It has been suggested that I use some simple socket programming to do this. Is this the best way? If not

8条回答
  •  野的像风
    2021-02-07 05:33

    You could use the Java Native Interface (JNI). The JNI allows you to make calls to C libraries from Java applications. Note that JNI calls are C and not C++ calls so you will have to specify the C calling convention on your C++ functions (extern "C").

    JNI has a reputation of being hard to do. It's not easy but it's certainly doable. I would advice against using sockets. Using sockets sounds like the easy way out but to me it is tantamount to opening a can of nasty worms...

提交回复
热议问题