[ACCEPTED]-UnsatisfiedLinkError: The specified procedure could not be found-java-native-interface
I figured out the problem. This was a doozy. The 29 message "The specified procedure could not 28 be found" for UnsatisfiedLinkError indicates 27 that a function in the root dll or in a dependent dll could 26 not be found. The most likely cause of 25 this in a JNI situation is that the native 24 JNI function is not exported correctly. But 23 this can apparently happen if a dependent 22 DLL is loaded and that DLL is missing a 21 function required by its parent.
By way of 20 example, we have a library named input.dll. The 19 DLL search order is to always look in the 18 application directory first and the PATH 17 directories last. In the past, we always 16 ran executables from the same directory 15 as input.dll. However, there is another 14 input.dll in the windows system directory 13 (which is in the middle of the DLL search 12 order). So when running this from a java 11 applet, if I include the code described 10 above in the applet, which causes input.dll 9 to be loaded, it loads the input.dll from 8 the system directory. Because our code 7 is expecting certain functions in input.dll 6 which aren't there (because it's a different 5 DLL) the load fails with an error message 4 about missing procedures. Not because the 3 JNI functions are exported wrong, but because 2 the wrong dependent DLL was loaded and it 1 didn't have the expected functions in it.
There is a chance that the DLL was built 5 using C++(as opposed to C). unless you took 4 care to do an extern on the procedure,this 3 is one possible reason.
Try exporting all 2 the functions from the DLL. If the list 1 includes your function, then you're good.
Usually, when linking to other libraries, you 5 need to link to the relevant .lib file. It 4 sounds like you aren't referencing all the 3 lib files you need. Check what isn't linking 2 and make sure you add it's lib to the list 1 for the linker.
Did you create the new external DLL using 9 the standard JNI procedure? I.e., using 8 javah and so forth? If so, then I am not 7 sure what is wrong.
If not, then the procedure 6 you're trying to call hasn't been exported 5 (as mentioned by anjanb). I am aware of 4 two way of exporting functions: a separate 3 export list and marking specific functions 2 with __declspec(dllexport).
Can't access variable in C++ DLL from a C app has a little 1 more information the topic of DLLs.
Compile your c++ code in debug mode. Then 9 insert the DebugBreak(); statement where 8 you would like to start debugging. Run 7 the java code. When the DebugBreak() statement 6 is encountered you will get a popup with 5 a Debug button on it. Click on it. Dev 4 Studio will open with your program in machine 3 code. Step over with the debugger twice 2 and you should be able to step over your 1 source code.
If you have done all programming issue at 8 JNI manuals and examples but still you are 7 getting same missing procedure error, problem 6 can be at your path variable probably. Do 5 below steps and run again:
- Be sure about you set JAVA_HOME variable to your JDK folder(not JRE because JRE doesnt contain jni header) Example: At environment variable settings panel define var:JAVA_HOME val:C:\Program Files\Java\jdk1.7.0_11
- add %JAVA_HOME%\bin to your path variable
After doing those 4 steps, your application can find jni procedure 3 name and links to JNI.dll in right way. So, i 2 hope you dont get this missing procedure 1 error again.
More Related questions