views:

724

answers:

5

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

+1  A: 

Have you looked at IKVM?

Jon Skeet
I'm looking for Java to Call .Net methods
Eduardo Santa
You could run the Java code within IKVM though - that's the point. If you really want to be running a "normal" JVM, have a look at the Eclipse project and how they integrated WPF - that had both a JVM and a CLR running in the same process, I believe. It's likely to be pretty messy though.
Jon Skeet
Sorry you are right. IKVM should work.
Eduardo Santa
+1  A: 

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.

RB
It is sooo easy to make evil mistakes on JNI, but it is definitively a workable solution. And as long as JNI defines some simple bridge, nothing too bad should happen
Mario Ortegón
Easy is an understatement!! With the NSIS bridge where the arguments are passed in on a stack structure (as I recall), we managed to get some lovely memory leaks!
RB
+1  A: 

We tried IKVM in our production environment but it kept crashing. We use JNBridge which is a commercial product but is very stable and performs well in our ASP.NET environment.

Tony Whalen
+3  A: 

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.

Nick Berardi
Exactly. jacob.dll + jacob.jar
Vladimir Dyuzhev
A: 

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.

Pavel Savara