Java generates a jar and uses IKVM to generate DLLs for C # calls

Source: Internet
Author: User
Tags file copy

Tag: Generate file copy 17. Import into the-O lips hint

Recently tried to use C # to do Nb_iot north to API interface access. North-to-API access requires two-way authentication of certificates, while C # does not support bidirectional authentication, so use IKVM to run Java programs in C # to implement the HTTPS request section.

The steps are as follows:

First, use Eclipse to write the north to the API to the Java part of the Code and packaging.

1. Code Writing

2. Generate Jar

3. Add the packages that are dependent on the project to the generated jar, because some dependent packages do not exist when the jar is generated, and it is convenient to add the dependency package to the jar in advance by using IKVMC to build the DLL one at a time without having to import the dependent packages in Ikvmc in turn.

Second, use IKVMC to generate the DLL, because the north of the API uses more than JDK8, so choose the ikvm-8.1.5717.0 version, the version supports JDK8

1. Copy the generated jar to Ikvm-8.1.5717.0\bin, use the command prompt to enter the directory, and use the Ikvmc-out:xx.dll Xx.jar command to generate the DLL.

Note: The use of the generated output can not be an error when the generation is unsuccessful, alarm information can be ignored according to the situation.

Third, the DLL will be generated with IKVM.Runtime.dll, IKVM. Runtime.JNI.dll, IKVM. OpenJDK.Core.dll copied to a C # project and referenced (PS: Copy the DLL directly here IKVM always reported that the file can not find the error, very tangled! I was able to add the corresponding version of IKVM through NuGet).

Write a program for C # and call it,

Run! Success!!!!

Java generates a jar and uses IKVM to generate DLLs for C # calls

Related Article

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.