views:

306

answers:

5

We have a major body of code in Java that runs on the desktop that we want to reuse with a MS.NET user interface (desktop rather than web). Any do's or don'ts would be very welcome.

+7  A: 

You may want to take a look at IKVM.

It is an implementation of the Java Virtual Machine on top of the .NET Framework. There are some parts dealing specifically with interoperability of the .NET and Java worlds so you can (more or less) seamlessly use one from the other.

Joey
Thanks Johannes, IKVN is on our list alright - if you have used it, did you find the bytecode to CLR reliable?
Chris Chedgey
Haven't used it yet, unfortunately. It's on my personal Todo list to play with it. But apparently they did have some success even with larger Java projects so it appears to be quite mature already, even though AWT/Swing support and security are lacking currently.
Joey
+5  A: 

I suggest creating web services for existing java code to act as a wrapper and call them from .net app. (desktop or web)

SoftwareGeek
+2  A: 

If you have the $$$$ you can try mainsoft; it converts your java code in C#, or vice versa, depending on your whim.

Eric Sink has a post about this.

Ngu Soon Hui
Thanks Ngu, we'll add that to the list - I don't mind paying reasonable $$$ for something that does the job.
Chris Chedgey
+1  A: 

Another possible solution could in the the form of j-interop

I've used it successfully for calling from Java -> DCOM and it claims to be able to do bi-directional stuff so in theory it should be possible to register a Java process as a DCOM server.

You will need to do a bit of work on the java side as it won't be able to just make it work automatically.

Gareth Davis
+1  A: 

I agree with the webservices method suggested by "2009MIPS". It offers the cleanest and most "debuggable" way to do it.

coolest_head