First, I realize that this is a JNI forum, but I am having a hard time finding a JNA forum.
I was hoping that someone here would be familiar enough with JNA to answer my question.
If not, then maybe I can use JNI to perform the tasks I need.
I know vitrually nothing about JNI or JNA, but it looked that JNA might be a bit less complicated to learn.
I have a c++ dll that contains a class named
CJNA_Test(void)
This class contains two functions
SetCallbacks and
TestCallbacks
I understand how to access functions from inside a dll - here is an example of my java class that sets up the function definitions.
package jnatest3;
import com.sun.jna.Native;
import com.sun.jna.Structure;
import com.sun.jna.win32.StdCallLibrary;
public interface IrisCapture extends StdCallLibrary {
public IrisCapture INSTANCE=(IrisCapture)Native.loadLibrary("IrisCapture",IrisCapture.class);
public void ICaptureInit();
public int ICaptureClose();
public int ICaptureOpen(String strAddress, String strSerial);
public int ICaptureStartIrisCapture( int purpose, int whichEye, int fedLevel, int timeout, int auditFace );
public int ICaptureStopIrisCapture();
}
And here is my test application
public class Main {
public static void main(String[] args) {
System.setProperty("jna.library.path","D:\\NetBeansProjects\\");
String s = System.getProperty("jna.library.path");
System.out.println( "Jna.library.path = "+s );
IrisCapture ic = IrisCapture.INSTANCE;
System.out.println( "IrisCapture: "+ic );
ic.ICaptureInit();
int i = ic.ICaptureOpen("192.168.0.200", "1234567890");
System.out.println( "Return from ICaptureOpen = "+i);
int purpose = 1; // Identification, Enroll
int whichEye = 2; // Right, left. both
int fedLevel = 0; // Fake eye detection 1 = detect, 0 = dont
int timeOut = 10000; // Time out in milliseconds
int auditFace = 0; // 1: Capture face image also; 0: don't capture
try
{
i = ic.ICaptureStartIrisCapture(purpose, whichEye, fedLevel, timeOut, auditFace);
System.out.println( "Return from ICaptureStartIrisCapture = "+i);
i = ic.ICaptureStopIrisCapture();
System.out.println( "Return from ICaptureStopIrisCapture = "+i);
}
catch (Exception e )
{
System.out.println( "Exception = "+e.getMessage());
}
i = ic.ICaptureClose();
System.out.println( "Return from ICaptureOpen = "+i);
}
}
The problem I am having is how do I instantiate and access a
class rather than a
function from within a dll?
How would I set up a java interfact to instantiate the class?
And, how would I access the class functions from within my main program?
I would prefer to get a JNA example, but a JNI example would work if I get some pointers on how to set
up access to dlls that contain classes and dlls that contain functions.
Thanks.