我正在发现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);
}
}