How to run JAVA Code under .NET Framework

How to run JAVA Code under .NET Framework

Have you think any trick that compile Java in .Net Framework or vice versa.  No or Yes Whatever your answer is but now I am going show you the trick in which our JAVA code will run under .net Framework. Before that let me introduce the some Technical Terms.

Mono:

Mono is a free and open source project led by Xamarin (formerly by Novell and originally by Ximian) to create an Ecma standard compliant .NET Framework-compatible set of tools including, among others, a C# compiler and a Common Language Runtime.

The stated purpose of Mono is not only to be able to run Microsoft .NET applications cross-platform, but also to bring better development tools to Linux developers. Mono can be run on many software systems including Android (and most other Linux distributions), BSD, OS X, Windows, Solaris, and some for game consoles such as PlayStation 3, Wii, and Xbox 360.[1]

But now we Here talk about IKVM.NET.

IKVM.NET:

IKVM.NET is 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 !!!

Follow the steps To Combine both the technology in your system. Suppose that if you are creating any project in c#.net, and add the advantages of JAVA in same project then this is the method.

Step 1:

Download the .Zip File from http://www.ikvm.net/download.html [2]. And unzip the folder, which look like this.

Figure 1

Step 2:

Create Project in C#.net and Add the Library of Java (IKVM) in  your project. All the required functionality of Java reside in .DLL file. So include the required DLL file in our System from bin Folder. In our case I am including following two DLL file in my system.

  1. IKVM.OpenJDK.Code
  2. IKVM.OpenJDK.SwingAWT

Figure 2

Figure 3

Figure 4

Step 3:

Now on From Load Event I have written following code.

Figure 5

Step 5:

Run the Code you will get Output as given Figure 6.

Figure 6

Citation       

[1] http://en.wikipedia.org/wiki/Mono_%28software%29

[2] http://www.ikvm.net/download.html

Share Post