IKVM
Listen to this article
As you're probably aware, some time ago I ported Simian to C# and ever since I've been maintaining two versions of the source code. This was becoming tiresome to say the least and recently I've been toying with installing VisualStudio.NET under VMWare to see if I can use J# instead. Not only did this idea urk me "just because", but the thought of installing anywhere up to 3GB worth of software that I would be forced to run under Windows just didn't impress me in the slightest.
If you're not up with the latest on mono you're probably unaware that the site has been overwhelmed for days now since the release of 1.0. Almost hidden within the distribution is IKVM.NET "an implementation of Java for Mono and the Microsoft .NET Framework." It includes the following components:
- A Java Virtual Machine implemented in .NET
- A .NET implementation of the Java class libraries
- Tools that enable Java and .NET interoperability
So, having just recently emerged the latest packages under Gentoo, I figured what the heck, I'll give it go.
First off, I tried ikvm. It's like a java.exe replacement. Where I would usually run:
java -jar simian.jar
I can instead run:
ikvm -jar simian.jar
Which will run simian under the .Net framework instead. And it worked. My jar was happily running under .NET with no code changes! But it gets better. The next step was to try ikvmc the compiler. Yes you heard it, a "static compiler used to compile Java classes and jars into a .NET assembly." So I gave it a whirl:
ikvmc simian.jar
It read the Manifest and determined where my main method was, "converted" all my classes and spat out an executable: simian.exe. So I ran it and once again, it worked first time. It just blew me away! No need to convert to C#. No need to installed Gigabytes of wizard-ware and best of all, the tools run under linux as well as windows.
So for a bit of extra bandwidth required to download the supporting DLLs, I can finally ditch all that lovingly hand-crufted C# code and deliver on just about any platform you can imagine!
I can't vouch for it's suitability with regards to your project but it's definitely worth a look if only for it's pure geek value. I'm sure yet another layer of indirection is exactly what you architects out there have been looking for. Just think, you too could have a Java application running under IKVM under .NET under Windows under VMWare under Linux ;-P
Comments
Simon,
Before you ditch the hand-crufted code, would you care to give some statistic comparisions?
I'd love to know things like performance times, size of download comparisions, memory use, etc.
Posted by: Robert Watkins | July 3, 2004 01:46 PM
Hehehe. Believe me I'm not throwing it out anytime soon. I haven't looked at the performance at all. But I will and let you know when I do. Remember, it only affects the .exe not the .jar
Posted by: Simon Harris | July 3, 2004 03:18 PM
Ok. Well I've done some VERY rough testing and the .NET conversion running under Windows UNDER LINUX seems to perform about the same than the previous C# version. However I don't recommend running the .NET version on linux! Stick with the Java version for now. That said, the previous .NET version never performed to well under mono. I'm still to get a straight windows machine and do a comparison.
Posted by: Simon Harris | July 3, 2004 03:46 PM
I discovered ikvmc the other day as well, and it was exactly what I was looking for, even though I didn't know it. We have a DotNet app that was using a COM component (created with VJ++ 6) that wrapped some MQ Java classes. I needed to change some stuff in the wrapper, but VJ++'s COM support is... interesting. Then I found out about ikvmc. I pulled the VJ code into Eclipse and output a single jar file (instead of a COM dll) then fed it and the MQ jar to ikvmc and ended up with two dlls that work perfectly. I'm very impressed. And the license is business-friendly to boot!
Posted by: Joey Gibson | July 8, 2004 01:46 AM
IKVM uses GNU Classpath for the class libraries. Stories like yours show that free implementations of runtimes for Java are getting quite useable. Spread the word :)
And of course, you could have never done that with Sun's business unfriendly source code license.
cheers,
dalibor topic
Posted by: Dalibor Topic | July 8, 2004 06:11 AM
Can I run Jython under java under IKVM under .NET under Windows under VMWare under Linux? Or are all those unders meant to be overs?
Posted by: john | July 8, 2004 11:32 PM
Hahahaha. Nice! ;-)
Posted by: Simon Harris | July 9, 2004 12:12 AM