If it is a Java project, you only need to put the DLL in SRC and set the run configuration. However, in a web project (according to the relevant data, 60% of users use Tomcat ), in this way, the DLL cannot be loaded at all.
There are always methods. The key is how to make system. loadlibrary ("testdll"); find the correct path. The following is my summary (I tried a lot of methods, but I can't do it. There are only 100% rows in this method ).
This method is:
Open the bin directory in the directory where your Tomcat is located. My directory is c: \ apache-Tomcat-7.0.6 \ bin and copy the DLL file to it.
In this way, you can run system. loadlibrary ("testdll") in the web project, and no unsatisfiedlinkerror will be reported.
However, an exception was reported when the server was actually deployed. I was quite depressed and later found that there were some other servers except tomcat.Program, That is, Tomcat is wrapped in a layer. Although Tomcat is started when the server is started, Tomcat is not the main program.
So I put the DLL file in the directory of startup. bat of the server, and the DLL is loaded successfully.
Based on this practice, I have summarized it into one sentence:
Find the directory where the main program runs (most of which are bin, except which may be packaged) and copy the DLL file. 100% run system. loadlibrary ("testdll.