简体   繁体   中英

Communicate Java and C#

I'm working on a project that uses an RFID reader, which only works with a library in C#. The thing is I'd really like to work with Java (develop the rest of the program, GUI, etc), and use the C# program just to ask the reader to read the information and return a string to the Java program.

So, is there a way I could do this?

Thanks in advance.

One way to approach this is to look at it as a problem of interprocess communication. There are a bunch of options (assuming Java has access to the necessary Windows API's which I'm assuming it does, but I'm not really a Java dev).

Named Pipes, TCP/IP, Filesystem, Mailslots, etc.

Here's a good article on some options: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365574(v=vs.85).aspx

Another option, which I don't know enough to speak about, is trying to load a .Net library into your java process.

Couldn't you use sockets? They both do support it, but I never tried to do it between different languages.
Good luck.

If you don't mind delving too deep you could use the Java Native Interface to generate code to marshall calls from Java to C# and back again. You'd need to build a "bridge" in c/c++ (c++ is generally slightly easier).

This way you get in-process communication, which is the fastest way to work :-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM