C # calling Java code (IKVMC)

Source: Internet
Author: User

Reference: 51406587

Reference 1:http://www.cnblogs.com/jack-blog/p/4710848.html?utm_source=tuicool&utm_medium=referral

Reference 2:HTTP://WWW.TUICOOL.COM/ARTICLES/EZJ7ZQR

Environment:

jdk-7windows-x64 (Friendly tip: Do not use the latest version of the JDK, jdk1.8 should not be)

Eclipse-jee-kepler-sr2-win32-x86_64

1. Download IKVM to http://www.ikvm.net/;

will not download to here under: http://download.csdn.net/detail/threadroc/9520165

After download, unzip, my decompression directory: D:\workspace\java\ikvm-7.2.4630.5

2. Setting IKVM Environment variables

Right-click My Computer, properties, advanced system settings, environment variables;

Add D:\workspace\java\ikvm-7.2.4630.5 to path under System variables (friendly tip: Don't forget the semicolon)

3. Export the jar package

Your project must have the package name assumed to be test_pkg

In Eclipse, select the project you want to export the jar to, right-->export-> check the jar file->next-> in the Java folder next->finish;

4.jar Turn DLL

Create a new folder named [temp], create a new folder named [Cd.bat] file, the file content is cmd

Copy the jar package you just exported to the folder;

Double-click Cd.bat to run

Enter Ikvmc-out:test.dll Test.jar (meaning to convert Test.jar to Test.dll, [Test] to your package name)

If your Java project refers to a third-party package. For example, I quoted a bag called Abc.jar and Qwe.jar.

You still need to use the command.

Ikvmc-out:abc.dll Abc.jar Convert the Abc.jar package to Abc.dll

Ikvmc-out:qwe.dll Qwe.jar Convert the Qwe.jar package to Qwe.dll

Then use ikvmc-target:library test.jar-r:abc.dll-r:qwe.dll (meaning to convert Test.jar to Test.dll and refer to Abc.dll and Qwe.dll)

5.c# Call

C # Reference

IKVM. OpenJDK.Core.dll

IKVM. Runtime.dll

IKVM. Runtime.JNI.dll

IKVM. OpenJDK.ClassLibrary.dll

IKVM. Openjdk.security

Several of the above can be found in the IKVM installation directory, not found in this download: http://download.csdn.net/detail/threadroc/9520211

Finally, it is possible to refer to the DLL compiled by Test.dll and its associated jar package.

Using test_pkg

You can call the Java code;

C # calling Java code (IKVMC)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.