问题描述
我正在尝试创建一个Java应用程序来管理时间卡。
为此,我开始编写一个小程序来完成与焊机的连接,我使用了JNI(Java Native Interface),这样我就可以使用随记录器提供的DLL中包含的功能。
不幸的是,经过几次尝试搜索我的程序产生的错误,我发现不知道该错误。
I am trying to make a Java application to manage a timecard.For this I began by writing a small program to do just a connection to the welder, I used JNI (Java Native Interface) so that I can use the functions contained in the DLL provided with the recorder.Unfortunately after several attempts to search for the error produced by my program I have found no idea about that error.
这是我程序的代码:
import system.reflection.Assembly;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.Native;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Variant;
import com.jacob.com.Dispatch;
public class Zkemkeeper {
static{
System.loadLibrary("zkemkeeper");
}
public static void main(String[] args) {
Zkemkeeper csc = new Zkemkeeper();
System.out.println("Result of adding = "+ csc.Connect_Net("192.168.0.201", 4370));
}
native boolean Connect_Net(String ip, long port);
}
控制台显示此异常:
推荐答案
zkemkeeper.dll似乎是DLL-COM而不是常规DLL。
zkemkeeper.dll seems to be DLL-COM not a regular DLL.
你应该使用Jacobgen来生成COM / Java接口和类为您服务。
我认为你不需要使用native和loadLibrary关键字也不需要使用JNA(但我对你的项目一无所知)。
You should use Jacobgen to generate the COM/Java interfaces and classes for you.I don't think that you need to use native and loadLibrary keywords nor JNA (but I know nothing about your project).
不要忘记注册你的zkemkeeper.dll正如他们网站上所解释的那样。
Do not forget to register your zkemkeeper.dll as explained on their website.
这篇关于JNI - 连接时间和考勤终端VF300的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!