<p>I have two programs. One is in C# and another one in Java.
Those programs will, most probably, always run on the same machine.</p>

<p>What would be the best way to let them talk to each other?</p>

<p>So, to clarify the problem:</p>

<p>This is a personal project (so professional/costly libraries are a no go).
The message volume is low, there will be about 1 to 2 messages per second.
The messages are small, a few primitive types should do the trick.
I would like to keep the complexity low.
The java application is deployed as a single jar as a plugin for another application. So the less external libraries I have to merge, the better.
I have total control over the C# application.
As said earlier, both application have to run on the same computer.
Right now, my solution would be to use sockets with some sort of csv-like format.</p>

[{'answer_id': 16697, 'author': 'John Downey', 'author_id': 200, 'author_profile': 'https://Stackoverflow.com/users/200', 'pm_score': 1, 'selected': False, 'text': '<p>I am a big fan of <a href="http://developers.facebook.com/thrift/" rel="nofollow noreferrer">Thrift</a> an interoperability stack from Facebook. You said they code will probably run on the same machine so it could be overkill but you can still use it.</p>\n'}, {'answer_id': 16700, 'author': 'Chris Farmer', 'author_id': 404, 'author_profile': 'https://Stackoverflow.com/users/404', 'pm_score': 2, 'selected': False, 'text': '<p>I used JNBridge (<a href="http://www.jnbridge.com/jnbpro.htm" rel="nofollow noreferrer">http://www.jnbridge.com/jnbpro.htm</a>) on a relatively simple project where we had a .NET client app using a relatively significant jar file full of business object logic that we didn\'t want to port.  It worked quite nicely, but I wouldn\'t say we fully exercised the capabilities of JNBridge.</p>\n'}, {'answer_id': 16712, 'author': 'Mark Cidade', 'author_id': 1659, 'author_profile': 'https://Stackoverflow.com/users/1659', 'pm_score': 3, 'selected': False, 'text': '<p>I\'ve heard good things about <a href="http://www.ikvm.net/" rel="noreferrer">IKVM</a>, the JVM that\'s made with .NET.</p>\n'}, {'answer_id': 16790, 'author': 'serg10', 'author_id': 1853, 'author_profile': 'https://Stackoverflow.com/users/1853', 'pm_score': 2, 'selected': False, 'text': '<p><a href="http://www.zeroc.com/ice.html" rel="nofollow noreferrer">Ice</a> from ZeroC is a really high performance "enterprisey" interop layer that supports Java and .net amongst others.  I think of it as an updated Corba - it even has its own object oriented interface definition language called <a href="http://www.zeroc.com/doc/Ice-3.3.0/reference/" rel="nofollow noreferrer">Slice</a> (like Corba\'s IDL, but actually quite readable).</p>\n\n<p>The feature set is extensive, with far more on offer than web services, but clearly it isn\'t an open standard, so not a decision to make lightly.  The generated code it spits out is somewhat ugly too...</p>\n'}, {'answer_id': 16857, 'author': 'Cheekysoft', 'author_id': 1820, 'author_profile': 'https://Stackoverflow.com/users/1820', 'pm_score': 3, 'selected': False, 'text': '<p>Kyle has the right approach in asking about the interaction. There is no "correct" answer without knowing what the usage patterns are likely to be.</p>\n\n<p>Any architectural decision -- especially at this level --  is a trade-off.</p>\n\n<p>You must ask yourself:</p>\n\n<ul>\n<li>What kind of messages need to be passed between the systems?</li>\n<li>What types of data need to be shared?</li>\n<li>Is there an important requirement to support complex model objects or will primitives + arrays do?</li>\n<li>what is the volume of the data?</li>\n<li>How frequently will the interactions occur?</li>\n<li>What is the acceptable communication latency?</li>\n</ul>\n\n<p>Until you have an understanding of the answers, or potential answers, to those questions, it will be difficult to choose an implementation architecture. Once we know which factors are important, it will be far easier to choose the more suitable implementation candidates that reflect the requirements of the running system.</p>\n'}, {'answer_id': 17344, 'author': 'Josh Brown', 'author_id': 2030, 'author_profile': 'https://Stackoverflow.com/users/2030', 'pm_score': 2, 'selected': False, 'text': "<p>I realize you're talking about programs on the same machine, but I've always liked the idea of passing messages in XML over HTTP.</p>\n\n<p>Your server could be a web server that's ready to accept an XML payload.  Your client can send HTTP messages with XML in the body, and receive an HTTP response with XML in it.</p>\n\n<p>One reason I like this is that HTTP is such a widely used protocol that it's easy to accept or create HTTP POST or GET requests in any language (in the event that you decide to change either the client or server language in the future). HTTP and XML have been around for a while, so I think they're here to stay.</p>\n\n<p>Another reason I like it is that your server could be used by other clients, too, as long as they know HTTP and XML.</p>\n"}, {'answer_id': 27537, 'author': 'jatanp', 'author_id': 959, 'author_profile': 'https://Stackoverflow.com/users/959', 'pm_score': 0, 'selected': False, 'text': "<p>If they are separate programs and running as independent applications,you may use sockets. I know it's bit complex to define communication protocol but it'll be quite straight-forward.</p>\n\n<p>However if you have just two separate programs but want to run them as single application, then I guess IKVM is a better approach as suggested by marxidad.</p>\n"}, {'answer_id': 1655210, 'author': 'Pavel Savara', 'author_id': 129124, 'author_profile': 'https://Stackoverflow.com/users/129124', 'pm_score': 4, 'selected': False, 'text': '<p>I am author of <a href="http://jni4net.sf.net/" rel="noreferrer">jni4net</a>, open source interprocess bridge between JVM and CLR. It\'s build on top of JNI and PInvoke. No C/C++ code needed. I hope it will help you.</p>\n'}, {'answer_id': 1739906, 'author': 'Thorbjørn Ravn Andersen', 'author_id': 53897, 'author_profile': 'https://Stackoverflow.com/users/53897', 'pm_score': 0, 'selected': False, 'text': '<p>It appears a very similar question has been asked before here on stack overflow (I was searching Google for java windows shared memory):</p>\n\n<p><a href="https://stackoverflow.com/questions/266913/efficient-data-transfer-from-java-to-c-on-windows">Efficient data transfer from Java to C++ on windows</a></p>\n\n<p>From the answer I would suggest you to investigate:</p>\n\n<blockquote>\n  <p>"Your fastest solution will be memory\n  mapping a shared segment of memory,\n  and them implementing a ring-buffer or\n  other message passing mechanism. In\n  C++ this is straight forward, and in\n  Java you have the FileChannel.map\n  method which makes it possible."</p>\n</blockquote>\n'}]
['https://Stackoverflow.com/questions/16689', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']