问题描述:

I have heard sometimes that the front end of a program was written in language A and the back end in language B. Can i do it for desktop programs I make too? Like do the graphics with Java and the back end with C or C++. How do i do it?

PS. Sorry if its a newbie question because I am one.

edit 1

Because i am told that my question is too broad, here is what I exactly want. How can I link mt action listener in java with a C program? For example, if i have a button "next hundred primes" i want the button to be made in Java and primes calculated using C.

网友答案:

This can be done in one Java process with JNI, for example. Java effectively calls C++ as a library.

This can also be done multi-process by having Java process create a C++ process then capture its output as, for example, C++ process exit code, standard output or created file.

A third way to do this would be to have a long-running C++ process listen on a TCP socket then have the Java program communicate with its C++ back-end over the network, either on the same machine or across an intranet.

Other methods also surely exist. These are just a few I know off the top of my head. :)

相关阅读:
Top