我的第二次拍摄是JNA,但是我得到了同样的错误,尽管你不需要在DLL中改变任何东西.
我创建了两个要测试的类:
接口:
package icom; import com.sun.jna.Library; public interface IConectorT extends Library { int StartConector(byte[] conectorStatus,String icomPath); }
package icom; import com.sun.jna.Native; public class ConectorTJna { public static void main(String args[]) { IConectorT lib = (IConectorT) Native.loadLibrary("ConectorT",IConectorT.class); int teste = lib.StartConector(null,"C:\\ICOM"); System.out.println("RESULT: " + teste); } }
当我调用lib.StartConector方法时,我得到这个:
Exception in thread “main” java.lang.UnsatisfiedLinkError: Error
looking up function ‘StartConector’: The specified procedure could not
be found. at com.sun.jna.Function.(Function.java:179) at
com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:350) at
com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:330) at
com.sun.jna.Library$Handler.invoke(Library.java:203) at
$Proxy0.StartConector(Unknown Source) at
icom.ConectorTJna.main(ConectorTJna.java:10)
以下是“JNA入门”指南中的详细信息:
Make your target library available to your Java program. There are two
ways to do this:
The preferred method is to set the jna.library.path system property to
the path to your target library. This property is similar to
java.library.path,but only applies to libraries loaded by JNA.Change the appropriate library access environment variable before launching
the VM. This is PATH on Windows,LD_LIBRARY_PATH on Linux,and
DYLD_LIBRARY_PATH on OSX.
取自:https://github.com/twall/jna/blob/master/www/GettingStarted.md