Download IKVM Required Components to IKVM's official website
Ikvm-0.40.0.1.zip
Ikvmbin-0.40.0.1.zip
Openjdk6-b12-stripped.zip
Unzip the Ikvm-0.40.0.1.zip and add%ikvm_home%\bin to the path. The%ikvm_home% here refers to the home directory of the IKVM after decompression.
Download IKVM.OpenJDK.ClassLibrary.dll to Debian IKVM.
Or go to rayfile to download data.tar.gz. This file can be extracted directly with WinRAR.
You need to download a simple tool Undeb to extract the. deb file.
You can also download to Rayfile
Extract the Ikvm_0.38.0.2+dfsg-2_all.deb file.
Create a new Java file package com.helloikvm.simple;
public class SimpleReturnString {
public String returnString() {
return "Hello, IKVM!";
}
public void throwException() throws Exception {
throw new Exception("Hello, Exception!");
}
}
Compile the simplereturnstring file, and then package it into a jar file, such as Ikvm.jar.
Use Ikvmc-out:ikvm.dll Ikvm.jar. You should now see a IKVM.dll file under the IKVM directory.
Create a new C #. NET project, first add the necessary DLLs
%IKVM_HOME%\BIN\IKVM. OpenJDK.Core.dll
%IKVM_HOME%\BIN\IKVM. Runtime.dll
%IKVM_HOME%\BIN\IKVM. Runtime.JNI.dll
IKVM. The DLL for this openjdk.classlibrary.dll[is in the Ikvm_0.38.0.2+dfsg-2_all.deb\usr\lib\cli folder. Or it can be found in the usr\lib\cli of the data.tar.gz. See step three and step fourth]
Add the 10th step generated IKVM.dll to C #. NET project, then a call to Java can be implemented using%package_name%.
Write C # code//import Java Package
using com.helloikvm.simple;
namespace IKVMTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnTest_Click(object sender, EventArgs e)
{
// Initialize the Java method
SimpleReturnString simpler = new SimpleReturnString();
// Call Java method
String returnString = simpler.returnString();
txtTest.Text = returnString;
}
}
}