Ryo Shinzo
Ryo Shinzo

Reputation: 51

Best way to exchange data between C# and executable JAR

I'm working with EXI, which encodes XML into a binary format and back.

For this I'm using the open source JAVA tool ExiProcessor, which is a executable JAR file and which makes this process very easy. Since I want to use it with C#, I need to exchange data between those two.

The easiest way is to write the XML data from C# to a file, read this file with ExiProcessor and then the other way round. But this isn't really fast.

Therefore I wonder what alternatives are there. I read that as of .NET Framework 4 you can use MemoryMappedFiles. I had a look, but it seems they only work between two applications that are using .NET Framework 4?

Is there any other way to speed up the process?

As a fallback I could use the JAVA sources and write my own application, but I would prefer to use the ExiProcessor as is.

Upvotes: 0

Views: 510

Answers (2)

JensG
JensG

Reputation: 13421

For mixed environments like this, Apache Thrift is usually a good choice. Thrift is designed for lightweight, fast and easy to use RPC (and IPC) solutions. Amongst others, it supports both Java and C#. Might be worth a look.

If you want to stick with MMFs, this is also possible by just using the serialization part of Thrift and read/write date into/from a buffer or stream. You don't have to use the RPC stuff.

Have a lok at this question for a more exhaustive overview and a few links to other resources that help you getting started quickly.

Upvotes: 1

Archangle
Archangle

Reputation: 322

I am not much sure , but if you are looking a way to use the jar,

You can try to convert the jar

http://www.ikvm.net/userguide/tutorial.html

or you can use a bridge like

http://jni4net.sourceforge.net/

hope this helps !!

Upvotes: 0

Related Questions