Java on .NET

By: on April 18, 2006

Prompted by Tony, I have played with ikvm, which allows you to run Java programs on .NET. Significantly it facilitates mixing and interop between Java and .NET code, i.e. Java code can call .NET libraries and .NET code can call Java libraries.

As a test, I tried running SISC under ikvm. Amazingly, “it just works”. Even calls to .NET libraries via SISC’s reflection-based Java interop interface work as expected:

C:programssisc-1.13.4sisc-1.13.4>set java=c:programsikvmbin-
SISC (1.13.4)
#;> (import s2j)
#;> (define-java-class <java.lang.System>)
#;> (define-generic-java-method println)
#;> (define-generic-java-field-accessor :out)
#;> (println (:out (java-null <java.lang.System>)) (->jstring "Hello, world"))
Hello, world
#<jnull void>
#;> (define-java-class <cli.system.console> |cli.System.Console|)
#;> (define-generic-java-method write-line |WriteLine|)
#;> (write-line (java-null <cli.system.console>) (->jstring "Hello, world"))
Hello, world
#<jnull void>

There are reports that people have managed to run tomcat on .NET this way!



  1. Chris Double says:

    ikvm is definitely cool. I’ve run Jetty (another Java webserver) and ran our continuation based web server written in Sisc using it under .NET and mono on Linux.

    I was pleasantly surprised to see it work. The whole setup used Jetty, HSQLDB (a java DB), various XSLT and XML transformers and custom Java libraries as well as Sisc. Pretty amazing.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>