1.JAVA 中pom坐标的引入
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
<version>5.2.0</version>
</dependency>
2.首先根据系统判断动态连接库的调用的类型
String os = this.systemParam();
if (os.toLowerCase().startsWith("windows")) {
return LzjStartLibrary.LIBRARY.NET_DVR_StartDVRRecord(lUserID, lChannel, lRecordType);
}
return LzjSoStartLibrary.LIBRARY.NET_DVR_StartDVRRecord(lUserID, lChannel, lRecordType);
3.接口调用方式
public interface LzjStartLibrary extends Library {
Boolean NET_DVR_StartDVRRecord(int lUserID, int lChannel, int lRecordType);
String dataDir = getConfig("system.win-dir");
LzjStartLibrary LIBRARY = Native.loadLibrary(dataDir, LzjJnaServiceImpl.LzjStartLibrary.class);
}
public interface LzjSoStartLibrary extends Library {
boolean NET_DVR_Init();
Boolean NET_DVR_StartDVRRecord(int lUserID, int lChannel, int lRecordType);
String dataDir = getConfig("system.data-dir");
LzjSoStartLibrary LIBRARY = Native.loadLibrary(dataDir, LzjJnaServiceImpl.LzjSoStartLibrary.class);
}