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

后端 未结 8 1757
太阳男子
太阳男子 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:21

    You have a few options:

    • Pass a file from Java to C++. This is probably simplest. It's easy to test and shouldn't require any 3rd party libraries on either end.
    • Use sockets as mentioned. In C++, if you require a cross-platform solution a library such as ACE or boost will save you some heartache
    • Use JNI to call from Java to C++ or vice versa. This is probably the most difficult, but most performant.

    For learning sockets, a Google search for "java socket tutorial" or "c++ socket tutorial" will give you lots of information.

提交回复
热议问题