Click here to Skip to main content
13,147,956 members (95,691 online)
Click here to Skip to main content
Add your own
alternative version


28 bookmarked
Posted 30 Dec 2008

Interoperability between a Java Virtual Machine and the CLR

, 7 Jan 2009
Rate this:
Please Sign up or sign in to vote.
With IKVM, you can run compiled Java code (byte code) directly on Microsoft .NET or Mono. The byte code is converted on the fly to CIL and executed.


IKVM.NET is an implementation of Java for Mono and the Microsoft .NET Framework. IKVM is free software, distributed under a permissive free software license.

IKVM 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

With IKVM, you can run compiled Java code (byte code) directly on Microsoft .NET or Mono. The byte code is converted on the fly to CIL and executed.

Using IKVM

Step 1: Write a Java class, e.g.,

// File '':
public class dllClass
    public static String foo() {
        return("STPL Inc");
    public static int add(int a, int b)
        int sum = a + b;
        return sum;
    public static int Mult(int a, int b)
        int mul = a * b;
        return mul;

Step 2: Compile it to get the class file dllClass.class.


Step 3: Again, convert it to a jar file dllClass.jar.

jar cf dllClass.jar dllClass.class

Step 4: Now, copy the jar file and copy it to IKVM/bin.

Step 5: Open Command Prompt, and go to IKVM/bin.

Step 6: Type IKVM and press the Enter key.


Step 7: Now, change the jar file to a DLL using this command:

Ikvmc dllClass.jar

We will now get the dllClass.dll file.

Step 8: Copy IKVM DLLs and dllClass.dll to the application bin directory.

Step 9: Add a reference to IKVM.OpenJDK.ClassLibrary.dll and dllClass.dll.

Step 10: Now, you can use this DLL in a C# code:

private void addbtn_Click(object sender, EventArgs e)
    int a = dllClass.add(Convert.ToInt32(textBox1.Text), 
    lblRs.Text = "Sum of " + textBox1.Text + 
                 " and " + textBox2.Text+" = "+a;

private void button1_Click(object sender, EventArgs e)
    int add = dllClass.Mult(Convert.ToInt32(textBox1.Text), 
    lblRs.Text = "Multi. of " + textBox1.Text + " and " + 
                 textBox2.Text + " = " + add;

private void button2_Click(object sender, EventArgs e)
    string  a =;
    lblRs.Text = a;

Result Screens




  • 30th December, 2008: Initial post
  • 6th January, 2009: Added source code and images to article


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Vivek Srivastava SSE
Software Developer (Senior) CloudXtension IT Solution, Gurgaon
India India
No Biography provided

You may also be interested in...


Comments and Discussions

QuestionMy vote of 5 Pin
Massimo Conti19-Apr-13 8:35
memberMassimo Conti19-Apr-13 8:35 
The subject is very interesting!
Thank you very much.
Great job!
GeneralMy vote of 1 Pin
Vitaly Shelest12-Apr-09 21:22
memberVitaly Shelest12-Apr-09 21:22 
GeneralMy vote of 1 Pin
Stan Alex8-Jan-09 1:13
memberStan Alex8-Jan-09 1:13 
GeneralMy vote of 2 Pin
Tarabanko Yury7-Jan-09 23:48
memberTarabanko Yury7-Jan-09 23:48 
GeneralMy vote of 1 Pin
Roberto Collina7-Jan-09 21:52
memberRoberto Collina7-Jan-09 21:52 
GeneralMy vote of 2 Pin
Lionel LASKE6-Jan-09 2:57
memberLionel LASKE6-Jan-09 2:57 
GeneralTechnical details Pin
Sohel_Rana31-Dec-08 16:45
memberSohel_Rana31-Dec-08 16:45 
GeneralInteresting! [modified] Pin
Dinesh Mani30-Dec-08 17:39
memberDinesh Mani30-Dec-08 17:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170915.1 | Last Updated 7 Jan 2009
Article Copyright 2008 by Vivek Srivastava SSE
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid