How can I call .NET code from Java?

I'm not looking for the usual answer like Web-services. I'm looking for a light solution to be run in the same machine.

Edit: I'm looking for way in Java to call .NET methods


Solution 1:

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

Solution 2:

I believe Java can talk to COM and .NET can expose COM interfaces. So that may be a very light weight solution that doesn't require any 3rd party. There is also the option of using sockets to communicate between the programs which wouldn't require a heavy instance of IIS to be installed on the machine.

Solution 3:

Have you looked at IKVM?

Solution 4:

Hve you looked into the Java Native Interface?

What I have done in the past is to write a C library, which is callable from both Java and .NET (and also COM, NSIS scripting language, and other technologies).

The JNI would work well if you only want to expose a few methods, but it might get unwieldy if you wanted to, for example, expose the entire .NET framework, because of the number of header files and wrapper methods you would need to create.