Java calling DLL method summary
JNI and jnative are commonly used. Note: when Java calls DLL, corresponding processing must be done in DLL. Columns such as: method name must be_ java_ Package name_ Class name_ Method name
Calling DLL steps using JNI
Create a new Java project and put the DLL file under Src
The configuration changes to the native directory under the project environment JRE, pointing to Src
The project JDK must not use the JDK provided by eclipse, but use the JDK path installed by yourself
Create a new directory and class according to the directory order in DLL
Declare the same method as in DLL, and add the native keyword before the method (pay attention to the parameter type)
Write in the static block of code (no suffix):
Then write the main method and you can call it. If an error is reported, pay attention to the error information. The dependent DLL file may be missing
Simple package JNI
Simply encapsulate a class that calls DLL
The code can be downloaded in resource sharing and my code
The calling code (mainly the static block code has changed), and the dllutil code is downloaded from the share
The above is the whole content of this article. For more content, you can search in programming tips. Thank you for your support.