JNA遇到的坑

记录一下,那些年我们踩过的坑

CLibrary Instance = (CLibrary)Native.loadLibrary("NLPIR",CLibrary.class);

有时候打包放在jar的平级目录能读到,其实jna是去这里找的:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'nlpirService' defined in class path resource [nlpir-rmi-server.xml]: Instantiation of bean failed; nested exception is java.lang.UnsatisfiedLinkError: Unable to load library 'NLPIR': Can't obtain InputStream for linux-x86-64/libNLPIR.so

用绝对路径:F:\\Desktop\\ICTCLAS2014\\lib\\win32\\NLPIR.dll 

乍看比较无厘头,来的目录,而且是相对路径,我们看看jna.jar就明白了

将NLPIR.so扔进去,程序可以跑了。。。


JNA遇到的坑