如何在Java中使用.dll
我有一些C#代码,我已经编译成.dll,作为其他程序的资源。如何将其导入Java项目以供使用,然后如何引用dll中的代码。我正在使用Eclispe for Java。我认为最简单的方法是使用JNA(Java Native Access)库,它简化了过程。 首先,下载jna.jar()并将其附加到项目中 稍后,用Java创建一个接口,该接口将以以下方式连接.dll库和Java代码:如何在Java中使用.dll,java,c#,dll,Java,C#,Dll,我有一些C#代码,我已经编译成.dll,作为其他程序的资源。如何将其导入Java项目以供使用,然后如何引用dll中的代码。我正在使用Eclispe for Java。我认为最简单的方法是使用JNA(Java Native Access)库,它简化了过程。 首先,下载jna.jar()并将其附加到项目中 稍后,用Java创建一个接口,该接口将以以下方式连接.dll库和Java代码: import com.sun.jna.Library; import com.sun.jna.Native; imp
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Platform;
public interface CLibrary extends Library {
CLibrary INSTANCE = (CLibrary) Native.loadLibrary(
(Platform.isWindows() ? "windowsDLLName" : "otherDLLName"), CLibrary.class);
void someMethof(String format, Object... args); // <--example function from dll lib
}
您必须涵盖以下主题:
CLibrary.INSTANCE.someMethod()