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):
Quote:
Method inside my DLL code
Code :
extern "C" __declspec(dllexport) int myMethod();
Quote:
corresponding JNA implementation
Code :
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:
Quote:
Class inside my DLL code
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?:confused:
Thanking in advance,
With regards,
Satya Prakash.
Re: Using JNA to access export native classes
Hello everybody,
Someone, please reply to this query. It's kinda urgent. Sorry, for the urgency, but atleast tell if it is possible or not? I am using JNA(Java Native Access) package for accessing native methods. Is it possible by the use of any other package like JNI or some other package?
Waiting for a reply,
With regards,
Satya Prakash.