aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes Calling a generic DLL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Calling a generic DLL" Watch "Calling a generic DLL" New topic
Author

Calling a generic DLL

Em Aiy
Ranch Hand

Joined: May 11, 2006
Posts: 226
Hi,

I want to call a generic dll from JAVA. The dll is provided by thirdparty. I am able to load it using "System.load("dllName.dll");" but i am now confused how can i call the methods. Since it is not made by me using JNI so there is not method with "native" keyword.

Is there any way to use its method?


The difference between <b>failure</b> and <b>success</b> is often being <b>right</b> and being <b>exactly right</b>.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14347
    
  22

You can't just call any function in a DLL using JNI.

What you can do is write an intermediate DLL yourself. Write a DLL (in C or C++) with functions that you can call from your Java code using JNI, and in your DLL call the functions in the third-party DLL.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Em Aiy
Ranch Hand

Joined: May 11, 2006
Posts: 226
Originally posted by Jesper Young:
You can't just call any function in a DLL using JNI.

What you can do is write an intermediate DLL yourself. Write a DLL (in C or C++) with functions that you can call from your Java code using JNI, and in your DLL call the functions in the third-party DLL.


For JNI, we must have a wrapper DLL as you said and That's what i don't wish to do. Writing the wrapper will take a lot of time. since it is third party dll.

Is there any other api, that can help me to call a dll?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Originally posted by Muhammad Ali Amin:

Is there any other api, that can help me to call a dll?


There are commercial products that do this, I think. It's not something you can just do, out of the box.

JNI questions go in our "Other Java APIs" forum, so I'll move this there.


[Jess in Action][AskingGoodQuestions]
Timothy Wall
Greenhorn

Joined: Sep 14, 2002
Posts: 14
Originally posted by Muhammad Ali Amin:
Hi,

I want to call a generic dll from JAVA. The dll is provided by thirdparty. I am able to load it using "System.load("dllName.dll");" but i am now confused how can i call the methods. Since it is not made by me using JNI so there is not method with "native" keyword.

Is there any way to use its method?


There are a few Java libraries that will let you do this:
JNA (http://jna.dev.java.net)
JNative (http://jnative.sf.net)
NLINK (http://nlink.dev.java.net)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calling a generic DLL