Recently in the project on JNI, encountered a very strange problem, always prompted java.lang.UnsatisfiedLinkError error. Only a partial solution was found on the Internet, and then I got it out of my way. This is explained in my method as follows:
Workaround: First put the generated dynamic link library under SRC, right-click the project name Select Build Path--> Configure builds path, change the native library in the source directory The location value is the folder location where the. dll file resides.
Condition 2: Before writing those Java code is written under Notepad, there is no build package. The eclipse operation was later used to find that only Java code could be placed under the default package to run successfully. But there's a new problem: Since jdk1.4, all classes can't invoke the class under the default package, which is a lot of trouble. I have to put these Java code in a package and run it again to prompt java.lang.UnsatisfiedLinkError errors. And then I figured, in the JNI step, "generate the. h file and then. dll ..." because the original Java file adds "package Com.jni." Again after the normal operation.
Condition 3: Write test code in Eclipse run normally, then add an adapter, change the interface, everything is OK. However, when I changed the test code to a servlet, that is, Java Engineering changed to Web engineering, again prompted Java.lang.UnsatisfiedLinkError error, the internet has not found a solution. Okay, I understand. This is because the library file is connected to a wrong location. So I searched the Xxx.dll file with everything and found that there was a. dll file underneath the project under WebApp, but build path can only edit one library location. Later, I copied the. dll file to the System32 folder, and found it miraculously good. As for why, I can only suspect that Tomcat also needs this link library.