Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a DLL from Java

Status
Not open for further replies.

cadbilbao

Programmer
Apr 9, 2001
233
ES
Hi!

I've just created a DLL with MS Visual C++ and I would like to call it from Java.

Anybody knows how to do it?

Regards,
 
try using the System.loadLibrary() method. haven't had to do it myself so not 100% sure about its workings.

best of luck :)
 
You have to use the JNI (JAVA Native Interface) API.
I did it a while back and I don't remember exactly how it's done but one of the things that really bothered me about it is that you have to write the function specifically for JAVA that you are calling (the function declaration is whacky too). On the java side if I remember correctly I think all you have to do is use the load library function, then after that declare the function prototype using the native keyword inside of a static block. Try at all costs to avoid using the JNI. I only recommend using it if you have to do something like OpenGL where you need really fast performance. Otherwise it's just not worth it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top