|
-
May 9th, 2011, 04:45 AM
#1
Using JNA to access export native classes
Hi everyone,
Currently I am working on java project which uses methods and classes present inside a DLL. Suppose I have such a method inside the DLL(named MyDLL.dll):
Method inside my DLL code
extern "C" __declspec(dllexport) int myMethod();
corresponding JNA implementation
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Platform;
/** Simple example of native library declaration and usage. */
public class HelloWorld {
public interface CLibrary extends Library {
CLibrary INSTANCE = (CLibrary) Native.loadLibrary("MyDLL", CLibrary.class);
int myMethod();
}
public static void main(String[] args) {
String libPath = "path to MyDLL.dll";
System.setProperty("jna.library.path", libPath);
int RetVar = CLibrary.INSTANCE.myMethod();
} ////main function ends
} ////class ends
So, my doubt is that like the function present inside the DLL, I have also got a class inside the DLL which needs to be exported:
Class inside my DLL code
extern "C" __declspec(dllexport) Class myClass
{
//////code inside class
};
So, now the question is how I am gonna use this native class inside my java code like i did for the native method?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|