Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / August 2006

Tip: Looking for answers? Try searching our database.

Loading of dll file

Thread view: 
vinaymvbhat82@gmail.com - 30 Aug 2006 07:58 GMT
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.
Philipp Leitner - 30 Aug 2006 09:04 GMT
> 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
Gordon Beaton - 30 Aug 2006 09:16 GMT
> 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



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.