IKVM basics


So, I’m not much of a java guy, but I need to know how to get at the CLI, given a java interface.

Let’s assume for brevity that one has an ubuntu machine available:

$ sudo apt-get install ikvm ikvm-native icepick icepick-gcj
....
$ mkdir hello-ikvm && cd hello-ikvm
$ cat > hello.java
class hello
{
  public static void main(String args[])
  {
    System.out.println("Hello, world!");
  }
}
^D
$ icepick-javac hello.java
$ ls
hello.class  hello.java
$ jar cvf hello.jar hello.class
$ ls
hello.class  hello.jar  hello.java
$ ikvm hello
Hello, world!

Okay, now we can run java bytecode on the IKVM virtual machine. yay. So what? On to the interesting bits.

$ ikvmstub mscorlib
...
$ ls
hello.class  hello.jar  hello.java  mscorlib.jar
$ cat > helloCLI.java
import cli.System.Console;

class helloCLI
{
    public static void main(java.lang.String args[])
    {
        Console.WriteLine("Hello, world!");
    }
}
^D
$ ls
hello.class  hello.jar  hello.java  helloCLI.java  mscorlib.jar
$ icepick-javac -classpath mscorlib.jar helloCLI.java
$ ls
hello.class  hello.jar  hello.java  helloCLI.class  helloCLI.java  mscorlib.jar
$ ikvmc -reference:mscorlib helloCLI.class 
$ ls
hello.class  hello.java      helloCLI.exe   mscorlib.jar
hello.jar    helloCLI.class  helloCLI.java
$ mono helloCLI.exe
Hello, world!

The end. I need to pick up Scarlet now.

, , , , , , , , , ,

Leave a Reply