Menu

Concepts

Small SQL

{{DeveloperGuide}}

IKVM.NET convert the Java byte-code into .NET IL code (Intermediate Language). This means the result is ever a .NET application. There are 2 modes for this conversion. On the fly with ikvm.exe and via a compiler with ikvmc.exe.

In both mode you convert byte-code and not the API. IKVM.NET is not a cross-compiler with exceptions. This means you need a Java runtime API in .NET. This are all the dll's of IKVM.NET. This are approximate 40MB overhead for your application. Depending of the used API some not used dll's can be removed if you are finish. This is not recommend.

There are also 2 types of code developments. You can write your code in any Java VM like Java or Scala. Or you write your code in any .NET language like C# or VB#. In the follow we will only speech from Java and C# also if any other language of this platform is possible.

Running on the fly

In this case you need to develop in Java code (see below). You need only to replace the Oracle or OpenJDK runtime with the IKVM runtime. In some cases it can help to rename ikvm.exe to java.exe. This is how you should begin. This mode is most compatible to Java.

The disadvantages is that this mode is very slow on start time. Every Java byte-code class need to converted to a IL class on every run. This is a large overhead for large projects.

More details can you find in a completely step by step example.

Running with compiler

I this mode you compile one or more jar files to a dll or exe file. It is recommended to compile every jar file to a separate dll or exe file. This start many faster as the on the fly mode.

The disadvantages is a switch from the Java class loading concept to the .NET class loding. This will discus in the [ClassLoader] topic.

Developing in Java code

To access .NET libraries in your Java code you create a stub file from a .NET library. This can you do with ikvmstub.exe. A IKVM.NET stub file is a *.jar file, a Java library. It contains only definitions of classes and methods. But it include no code. If you run a stub file with the Oracle Java VM or OpenJDK you receive an error.

The .NET classes start ever with the package cli.

Some .NET constructs require a specific syntax in Java. This are list in [Using_.NET_with_Java].

Developing in C# code

This is only possible with compiler mode. You compile you jar files to a dll or exe. Add it as reference to your IDE. You can use every class and method like from any other .NET library.

Some Java constructs require a specific syntax in .NET. This are list in [Using_Java_with_.NET].

See the step by step example for details.


Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.