Thursday, February 05, 2009

.Net and Java Inteoperability

I recently was saddled with the task of developing a component for a Telecoms (GSM) company. This is a company that has huge investment in Java-based applications on Sun Solaris boxes. The requirement of the component warrants a need to connect my ASP.Net based application to an existing connection pooling java-based socket application.

Immediately, interoperability comes to mind. Which is best? Some of the thots that came to mind are

- Use JNBridge (license cost)
- use a message based intermediary (MSMQ - requires modification of Java component which not allowed)
There is a whole lot of options in this space which I will not want to go into in this blog

- IKVM.Net (read all about this but not sure it works)

Other constraint is I had budget constraint that knocks off JNBridge and also not allowed to modify the service component as some other production applications depends on it. Whick left me with IKVM.Net.

First, I wrote a Java client application that uses this service, compiled and tested it well, then I use IKVM to generate a .Net dll off this java class file and Voila!, task got done!. It's no trouble getting this into my ASP.Net bin folder.


> javac SVClient
> ikvmc SVClient -target:library


Refer to IKVM.Net tutorial

The great thing about IKVM is that it works without any dependency to the original java class file. It's a complete conversion of the java code.

I got curious a bit and opened the dll in Red Gate's .Net Reflector and learned a lot on what underlying code.

No comments: