如何从C#.Net调用Java函数/类 [英] How to Call Java Functions/Classes From C#.Net

查看:119
本文介绍了如何从C#.Net调用Java函数/类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

下午好.

我有一个包含两种方法的应用程序
该应用程序是用Java编码的.

如何从VS C#.net调用Java方法.

有人可以帮我吗?

谢谢与问候
Lakshman CB

Hello,

Good Afternoon.

I have an Application Containing Two methods
The application is Coded in Java.

How Can I call Java methods from VS C#.net.

can anyone Help me?

Thanks and Regards
Lakshman C B

推荐答案

从一个快速的Google网站(您应该先尝试过),这些人 [ ^ ]提供了付费解决方案,尽管我不知道.不知道多少钱.

没有简单的方法,因为两个VM完全不兼容.您需要在两侧编写通信/编组代码,或使用为您编写通信/编组代码的工具(例如Web服务).

如果双方都可以控制源代码,那么如果最终目标平台是.Net,则最好用.Net语言重写Java部分.这取决于代码与Java库的集成程度,等等,在Framework中没有直接等效的方法.
From a quick Google (which you should have tried first), these guys[^] offer a paid-for solution, though I don''t know how much it is.

There is no simple way, as the two VMs are completely incompatible. You need to write communication/marshalling code on both sides, or use a tool which writes it for you (for example web services).

If you are in control of the source code on both sides it may be best to rewrite the Java part in a .Net language, if .Net is your target final platform. That depends on how deeply integrated the code is with Java libraries etc that there is no direct equivalent for in the Framework.


您可以做一件事:使用某些产品将Java代码移至.NET.将Java作为.NET和Mono的语言实现.

这样的产品之一就是IKVM.NET, http://en.wikipedia.org/wiki/J_Sharp [ ^ ].根据许可 zlib许可,该产品是免费的, http://en.wikipedia.org/wiki/Zlib_License [ ^ ].

这样的另一个选项是J#,但是现在不支持该项目,请参见 http://en.wikipedia.org/wiki/J_Sharp [ ^ ],http://msdn.microsoft.com/en-us/vjsharp/default.aspx [ http://www.janetdev.org/ [
You could do one thing: move Java code to .NET using some product implementing Java as language for .NET and Mono.

One such product is IKVM.NET, http://en.wikipedia.org/wiki/J_Sharp[^]. The product is free, under permissive zlib License, http://en.wikipedia.org/wiki/Zlib_License[^].

Another option like this is J#, but this project is not supported now, see http://en.wikipedia.org/wiki/J_Sharp[^], http://msdn.microsoft.com/en-us/vjsharp/default.aspx[^].

The last choice from this row is Ja.NET, see http://www.janetdev.org/[^], also Open Source.

I would look at IKVM.NET first.

—SA


看看 Jni4Net [ ^ ]-它是免费的,并且运行良好-实际上,它非常强大: )

最好的问候
Espen Harlinn
Have a look at Jni4Net[^] - it''s free and works fairly well - actually it''s pretty powerful :)

Best regards
Espen Harlinn


这篇关于如何从C#.Net调用Java函数/类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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