Angelo Lee's Blog
This is my kingdom .If i don't fight for it ,who will ?

Introduction:

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

IKVM.NET is a JVM for the Microsoft .NET Framework and Mono. It can both dynamically run Java classes and can be used to convert Java jars into .NET assemblies. It also includes a port of the OpenJDK class libraries to .NET.

Official Website:http://www.ikvm.net/

 

Uses for IKVM.NET

IKVM.NET is useful for several different software development scenarios. Here is a sampling of some of the possibilities.

 

IKVM提供2种主要的方式在.NET平台上运用Java项目。

动态方式,即通过IKVM .NET实现的JVM直接运行Java项目,这种方式需要动态的将Java的class或者jar等文件编译成.NET的CIL, 所以启动的时候会比较慢。

静态方式,即使用IKVM的工具先将class、jar文件编译为.NET的CIL程序集,然后在.NET framework上运行这些程序集,这种方式可以在.NET开发中直接使用Java的类库
项目组件、程序集介绍参考这里:

 

IKVM对于2中状况比较有用:

一种Java中的一些项目没有.NET实现的。

另一种是某些Java开源项目存在相应的.NET port,但Java的项目很活跃一直在完善更新,而.NET port则停滞了。

对于纯粹基于JDK的Java项目,IKVM目前应该能够处理的比较完善了, 对于使用了Swing和JNI的Java项目,IKVM也有提供支持,但不了解支持程度以及稳定性等方面。
项目使用的lisence值得考虑,IKVM.OpenJDK.*.dll使用GPL V2,其他的IKVM项目文件使用的lisence应该是BSD之类的。

 

Download IKVM from official website and unpack to special directory

IKVM.NET  Component

  • IKVM.Runtime.dll 是虚拟机运行时和所有支持的代码。包含如下:

1)Byte Code JIT 编译器/验证器。JIT 把 Java Byte Code编译成 CIL(C中间语言)。

2) 重映射基础结构的对象模型。

   将.NET中的System.Object,System.String,System.Exception映射为JAVA代码中的java.lang.Object, java.lang.String,java.lang.Throwable。

3) 在 Classpath 中重实现托管的.NET 的本地方法。

  • ikvm.exe 是相当于精简的、可执行文件 java.exe(“dynamic mode”)。
  • ikvmc.exe 是静态编译器。用来把 Java 类和 jar 包编译成 .NET 程序集(“static mode”)。
  • ikvmstub.exe 是从 .NET 程序集生成 stub 类文件的一个工具,这样,Java 代码就可以被编译成 .NET 代码。IKVM.NET 根据stub,引用被真正的 .NET 类型的引用替换。
  • 为.NET程序集生成Java class的代理文件,以便在Java中使用.NET程序集的功能
  • Compiling a Jar Into An Assembly
posted on 2013-03-20 21:48  Angelo Lee  阅读(306)  评论(0编辑  收藏  举报