> Hi,
> I had a doubt in java related to loading of dll files.The first thing
> is how to load the dll file in java and then how to retrive the
> methods/functions from the dll files.Can anybody help me, please.
I am not sure what you mean with "load", but if you think about calling
functions of the DLL you'll definitely be out of luck with pure Java -
you need to go over the native interface (JNI) as soon as you want to
integrate with C(++) program code.
/philipp
> I had a doubt in java related to loading of dll files.The first thing
> is how to load the dll file in java and then how to retrive the
> methods/functions from the dll files.Can anybody help me, please.
System.load() or System.loadLibrary() will load a DLL.
If it's been written specifically for use with Java, the methods it
contains will belong to Java classes. You can use those methods the
same way you use any Java methods, i.e. you don't do anything
different just because they're in a DLL.
If it hasn't been written for use with Java, then you need to create a
new DLL that follows the rules and naming conventions of JNI and load
*that* instead. From there, you can make calls to the original DLL.
/gordon

Signature
[ don't email me support questions or followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
vinaymvbhat82@gmail.com - 31 Aug 2006 06:39 GMT
Hi,
Thanks for the reply, Now i have loaded the dll file using Regsvr32
command option from the windows.Now the problem is how do i import this
in my java application and use the inbuilt methods.
> > I had a doubt in java related to loading of dll files.The first thing
> > is how to load the dll file in java and then how to retrive the
[quoted text clipped - 16 lines]
> [ don't email me support questions or followups ]
> g o r d o n + n e w s @ b a l d e r 1 3 . s e
Gordon Beaton - 31 Aug 2006 07:31 GMT
> Hi,
> Thanks for the reply, Now i have loaded the dll file using Regsvr32
> command option from the windows.Now the problem is how do i import this
> in my java application and use the inbuilt methods.
As I wrote earlier, you need to write your own DLL that follows the
JNI rules and naming conventions. For example, consider this Java
class:
public class MyClass {
public native int foo(int a);
[ ...and other methods...]
}
Note that MyClass has a native method foo(), which is found in a DLL
that has been written expressly for the purpose of implementing one or
more of the methods of MyClass:
JNIEXPORT jint JNICALL Java_MyClass_foo(JNIEnv *env, jobject this_foo, jint a)
{
return some_other_function(a);
}
From native methods like this one, any other functions can be invoked,
including those in your existing DLL.
You need to write a set of native methods like foo() that bridge
between your Java application and the library functions you want to
use.
Start reading here:
http://java.sun.com/j2se/1.5.0/docs/guide/jni/index.html
http://java.sun.com/docs/books/jni/index.html
/gordon

Signature
[ don't email me support questions or followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e