Calling C# code from Java?

You would use the Java Native Interface to call your C# code compiled into a DLL.

If its a small amount of C#, it would be much easier to port it to Java. If its a lot, this might be a good way to do it.

Here is a highlevel overview of it:

http://en.wikipedia.org/wiki/Java_Native_Interface

Your other option would be to create a COM assembly from the C# code and use J-Interop to invoke it.

http://sourceforge.net/projects/j-interop/


I am author of jni4net, open source intraprocess 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.


If it's short, I think you're better off re-writing the code in java. Downloading one 50Mb runtime is bad enough.