This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
I have a dll with few methods I'd like to call. Problem is I don't have any API for it.
I'm using Dll Export Viewer to see what functions are available.
Most of the functions have signature like this:
There is one which is just called:
I'm using JNA to load and invoke dll methods. When I invoke the testMethod it works just fine, so I assume that the dll lib is loaded properly. Problem is with other methods. I can't call them using full "_Java_something_MethodName" or just "MethodName". Is it a diffrent type of method, is it somewhere else not in the loaded dll, is there diffrent way to invoke such method?
The Exception thrown when trying to invoke those methods is:
Are you sure these functions* start with _Java, and not Java? Because they look like JNI functions. If you create a native method in Java, then use javah to create a header, that header includes a lot of functions in the following format: Java_<full class name with . replaced by _>_<method name>. For example, if your class is com.coderanch.test.MyClass and it has a native method runTest, then function Java_com_coderanch_test_MyClass_runTest will be created.
That said, these JNI functions shouldn't be called directly but through their native methods in Java. It's a wonder you even managed to properly create the required JNIEnv and jobject / jclass values required to call these JNI functions.
I'm a newbe to native methods so I don't understand few things. The whole aplication which contains mentioned dll file is a Java Applet. This applet contains a dll file. The applet class contains simple methods like init, some checks and native methods FindSomething, GetSomething and others. Are those the methods which I see in Dll Export View as _Java_something_FindSomething@8 etc? Or are those methods placed somewhere else?