Use a .jar java library API in C#?

前端 未结 3 2060
一生所求
一生所求 2020-11-27 10:32

I\'m an entry level programmer so please be descriptive in your responses.

I am trying to use a Java API given as a .jar file in my C# .net application. I don\'t kn

相关标签:
3条回答
  • 2020-11-27 11:05
    1. You could use IKVM.NET - http://www.ikvm.net/userguide/ikvmc.html

      On the official website in download - you can get ikvmbin-7.2.4630.5 (Works up to Java 7)

      However, on the owner's blog, you can download a newer version. http://weblog.ikvm.net/default.aspx - You can get ikvmbin-8.1.5717.0 (Works up to Java 8)

      To create dll/exe use:

      ikvmc hello.jar

    2. On the other hand, if you can edit .jar lib (you created it) you could use http://jni4net.com/ project.

    0 讨论(0)
  • 2020-11-27 11:16

    Have a look at IKVM ... it has tools to give you some level of interop. When you say Java API I assume you want to call some functionality from the jar rather than just execute it

    0 讨论(0)
  • 2020-11-27 11:20

    You can do it using IVKM.Net. IVKM.NET includes an application called ikvmc. Here’s the documentation for this tool:

    http://www.ikvm.net/userguide/ikvmc.html

    To use it compile your java code into a Jar.

    Then run the ikvmc program:

    ikvmc myCode.jar

    If your jar contains a main() function, it will be converted into an exe that can be run on the CLR. Otherwise it will be converted into dll’s. To use the dll’s in your project just add them as references in Visual Studio and the same API that was available to you in Java will be accessible in your .Net application.

    You can also include the IKVM.GNU.Classpath.dll dll from ikvmc and use the standard java class libraries in your application.

    0 讨论(0)
提交回复
热议问题