我发现了jni4net。这是用于提供Java和.NET之间桥梁的技术。因此,我创建了新的Eclipse Java项目,并将示例代码从jni4net-0.8.6.0-bin / samples / myCSharpDemoCalc-> MyCalcUsageInJava.java复制到此项目中。但是无法编译代码,因为无法找到两个导入“mycsharpdemocalc.DemoCalc”和“mycsharpdemocalc.ICalc”。我不明白如何将mycsharpdemocalc.c集成/导入到Java项目中,以便编译代码。
import net.sf.jni4net.Bridge;
import java.io.IOException;
import mycsharpdemocalc.DemoCalc;
import mycsharpdemocalc.ICalc;
public class MyCalcUsageInJava {
public static void main(String arsg[]) throws IOException {
Bridge.init();
Bridge.LoadAndRegisterAssemblyFrom(new java.io.File("MyCSharpDemoCalc.j4n.dll"));
ICalc calc = new DemoCalc();
final int result = calc.MySuperSmartFunctionIDontHaveInJava("Answer to the Ultimate Question of Life, the Universe, and Everything");
System.out.printf("Answer to the Ultimate Question is : " + result);
}
}