Wednesday, December 26, 2001 05:34 AM
In Win32, DLLs are not language-specific. Calling a function in a DLL should be just like calling any other native method:
- Create a Java class with native methods with the required names/argument lists for your DLL call.
- Compile the java file into a CLASS and also have the JDK create your C
- Within this generated C file, have your 'proxy' method load and call the function in your DLL.
- Compile your C file and link it as a shared library (DLL in Win32).
- In your main program, call
- Then, create an instance of your proxy object and call the native method.
Here's the flow of information:
Main program -> java proxy object -> C proxy object -> target DLL function
If you want to return information from your DLL call, you'll have to wrap the return values (int, long, char *, etc) in their Java wrappers before returning from your C function.
Check out the JNI FAQ here on JGuru, as well as Sun's JNI tutorial in their online tutorial.