使用C#中的.jar Java库的API? [英] Use a .jar java library API in C#?

查看:233
本文介绍了使用C#中的.jar Java库的API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个入门级的程序员,所以请大家多多包涵,并描述在你的反应。

I'm an entry level programmer so please bear with me and be descriptive in your responses.

我想使用给定在我的C#.net应用程序.jar文件的Java API。我不知道很多Java,但是这个.jar文件说:无主级表现属性当我尝试运行它,所以这意味着它的图书馆?这个Java API还配备了一个.java文件展示了如何使用图书馆,但我看不到的.jar里面的code。

I am trying to use a Java API given as a .jar file in my C# .net application. I don't know much Java, but this .jar file says "no main-class manifest attribute" when I try to run it so this means its a library? This Java API also comes with a .java file which shows how to use the library but I cannot see the code inside the .jar.

我发现这个问题在这个网站,答的人读, 在简单的方式,你可以收拾你的java类的jar文件,然后在C#中使用Process类为执行和地图IO流。我半熟悉C#过程类,但我不明白我怎么可以用它来使用Java库在我的C#.NET项目。

I found this question on this site, and one of the answers reads, "In simple way you can pack your java classes to jar file then In C# use Process class for execute and map IO stream." I am semi-familiar with the Process class in C# but I don't understand how I could use it to use a Java library in my C# .net project.

这可能吗?或者是这个问题的答案不正确?

Is this possible? or was that answer incorrect?

如果是这样,你能解释我如何可以使用的.jar库在我的C#应用​​程序。

If so, could you explain how I can use the .jar library in my C# app.

在此先感谢。

推荐答案

您可以使用IVKM.Net做到这一点。 IVKM.NET包括所谓ikvmc的应用程序。下面是该工具的文档:

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

要使用它编译Java code成JAR。

To use it compile your java code into a Jar.

然后运行ikvmc程序:

Then run the ikvmc program:

ikvmc我的code.jar

ikvmc myCode.jar

如果你的罐子中包含一个main()函数,将它转换成可以在CLR上运行的exe文件。否则,将被转换成dll的。使用DLL的在你的项目中只需添加它们在Visual Studio中,那就是提供给您的Java将在你的.NET应用程序访问相同的API的参考。

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.

您还可以包括从ikvmc的IKVM.GNU.Classpath.dll DLL并在应用程序中使用标准的Java类库。

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

这里有一个博客帖子我做了这件事

这篇关于使用C#中的.jar Java库的API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆