开发者

How to make Java and C programs communicate together [closed]

开发者 https://www.devze.com 2022-12-28 21:03 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 10 years ago.

I have written a command line interface program in the C language. This kind of programs (as you k开发者_C百科now) waits for user commands typed in the terminal and reacts on depend of them. In fact, the program implements a callback function which parses the command and invokes the appropriate function in order to respond to the user.

Now, I have to make a Java GUI (Graphical user interface) for the desktop (Ubuntu) version of this program and then port the same program to the Android Platform (of course the GUI will respect Android framework), so I'm looking for the best way to do it.

I have heard about JNI and JNA and I don't known which one will be the best for me. By the way what are the main differences between JNI and JNA.

And what about the others IPC techniques and middle-ware (like DBUS).

Any suggestion will be appreciated.

Thanks in advance.


If your program's functionality is completely available through the command line (and it only works through simple commands rather than a curses-based full-screen interface), then it would probably be easier to just have the GUI interface with the C program through the command line rather than messing with JNI.

Simply use ProcessBuilder to start the program and communicate with it through its stdin and stdout streams.

0

精彩评论

暂无评论...
验证码 换一张
取 消