[英]JNI: Call C# method from Java
I want to call C# method from Java using JNI. 我想使用JNI从Java调用C#方法。 I have the DLL as well as the exe with me. 我有DLL以及exe。 Hello world program in C# looks like: C#中的Hello world程序如下所示:
using Test;
{
clsMain tst = new clsMain;
clsInput input = new clsInput;
clsOutput output = new clsOutput;
input.strTekstInput = "John";
output = tst.funMain(input);
MsgBox(output.strTekstOutput);
}
I want to call this method and print the output using JNI. 我想调用此方法并使用JNI打印输出。 But I am not sure how to achieve this as I have never used JNI. 但是我不确定如何实现此目标,因为我从未使用过JNI。 Can someone help with What I need to do here? 有人可以帮我在这里做什么吗? Appreciate response. 感激之情。
regards, Venky 问候,Venky
Actually, you cannot directly call the C# method from Java code but you can write C++ wrapper. 实际上,您不能直接从Java代码调用C#方法,但可以编写C ++包装器。 This C++ wrapper can be get called from Java code and eventually this C++ wrapper can call C# method. 可以从Java代码调用此C ++包装器,最终,该C ++包装器可以调用C#方法。
So it would be like this: Java --> C++ Wrapper --> C# 就像这样:Java-> C ++ Wrapper-> C#
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.