How to call VB Dll In Java?
1 posts in topic
Flat View  Flat View

Posted By:   Sumukh_Bhagwat
Posted On:   Wednesday, December 26, 2001 04:12 AM

pls can any body tell me how to call VB Dll In Java it should be only VB related not C C++ related. i.e.
the answer should be related to only to VB not to C, C++

Re: How to call VB Dll In Java?

Posted By:   Christopher_Schultz  
Posted On:   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:

  1. Create a Java class with native methods with the required names/argument lists for your DLL call.
  2. Compile the java file into a CLASS and also have the JDK create your C .h and .c files.
  3. Within this generated C file, have your 'proxy' method load and call the function in your DLL.
  4. Compile your C file and link it as a shared library (DLL in Win32).
  5. In your main program, call System.loadLibrary("myLibrary");
  6. 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.

About | Sitemap | Contact