今日遇到此问题:JNA异常java.lang.UnsatisfiedLinkError: Unable to load library
代码如下:
public class IcMultiApp implements IIcMultiApp{
public interface IIcMultiApp extends Library {
String sep = File.separator;
IIcMultiApp INSTANCE = (IIcMultiApp)Native.loadLibrary("."+sep+"driver"+sep+"scms", IIcMultiApp.class);
public int PBOC20_HT_READINFO(byte[] s1,byte[] s2,byte[] s3,byte[] s4);
public int PBOC20_HT_WriteScriptFromFile(String s0,byte[] s1,byte[] s2,byte[] s3,byte[] s4);
}
static IIcMultiApp dll=IIcMultiApp.INSTANCE;
……
}
经查:是由于动态库链接的路径问题,导致的无法加载。
将路径改成绝对路径:
IIcMultiApp INSTANCE = (IIcMultiApp)Native.loadLibrary("E:"+sep+"yunbao"+sep+"代码"+sep+"3.cvs"+sep+"workspace_srcb"+sep+"cn.com.agree.device.icmultiapp"+sep+"driver"+sep+"scms", IIcMultiApp.class);
即可解决