Patrick Toy
Patrick Toy

Reputation: 41

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?

Upvotes: 4

Views: 1567

Answers (3)

11684
11684

Reputation: 7507

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

Upvotes: 1

RB.
RB.

Reputation: 37192

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 :-)

Upvotes: 0

Dylan Smith
Dylan Smith

Reputation: 22245

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.

Upvotes: 1

Related Questions