我有一个
Java项目,使用
this driver进行串行通信.驱动程序使用Windows下的dll来创建串行端口.
该项目包含几个JUnit测试,使用“运行为 – > JUnit测试”成功完成.但是,当运行ant(和不引用本机库通过的测试)时,引用本机库的测试失败.
到目前为止,我最好的猜测是将包含本机库的目录添加到java.library.path中,但是我没有通过build.xml文件成功.
有人可以告诉(干净)解决方案吗?
这是我的build.xml:
这里是测试报告的一部分(以XML格式):
java.lang.UnsatisfiedLinkError: giovynet.nativelink.SerialPort.getStateSerialPortC(Ljava/lang/String;)Ljava/lang/String;
at giovynet.nativelink.SerialPort.getStateSerialPortC(Native Method)
at giovynet.nativelink.SerialPort.getFreeSerialPort(SerialPort.java:50)
at package.comport.GioComport.getFreeSerialPorts(Unknown Source)
at package.comport.GioComport.findDevice(Unknown Source)
at package.comport.GioComport.<init>(Unknown Source)
at package.comport.ComportFactory.createNewPort(Unknown Source)
at package.comport.ComportFactory.createComport(Unknown Source)
at package.comport.test.buildservertests.ComportFactoryTest.testCreateDefaultComport(Unknown Source)
java.lang.UnsatisfiedLinkError: giovynet.nativelink.SerialPort.getStateSerialPortC(Ljava/lang/String;)Ljava/lang/String;
at giovynet.nativelink.SerialPort.getStateSerialPortC(Native Method)
at giovynet.nativelink.SerialPort.getFreeSerialPort(SerialPort.java:50)
at package.comport.GioComport.getFreeSerialPorts(Unknown Source)
at package.comport.GioComport.findDevice(Unknown Source)
at package.comport.GioComport.<init>(Unknown Source)
at package.comport.ComportFactory.createNewPort(Unknown Source)
at package.comport.ComportFactory.createComport(Unknown Source)
at package.comport.test.buildservertests.ComportFactoryTest.testCreateComportWithWrongSettings(Unknown Source)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1738)