On Aug 20, 2007, at 2:20 PM, Kay W wrote:
I am a newbie at JNA and need some assistance. First let me explain
what I am trying to do:
I have an unmanaged DLL (I do not have the source code). I would
like to create a Java wrapper around this DLL. After several days
of intense frustration I have given up on implementing the wrapper
using JNI, due to an exception that I cannot resolve. I have thus
turned to JNA.
The problem is, I cannot get my JNA code to compile. I am sure that
I must be missing something simple. I have include my code below as
well as the build error.
Java Code
-------------------------------------------------------
Rda2Server.java
---
package rda2;
import com.sun.jna.*;
public interface Rda2Server extends Library {
Rda2Server INSTANCE = (Rda2Server)Native.loadLibrary("RDA2",
Rda2Server.class);
public void Connect(String DataPath, long Workstation, String
Username, String Password);
public void Disconnect();
public boolean Connected();
}
rda2.java
---
package rda2;
import com.sun.jna.*;
public class rda2 {
Compilation Error
---------------------------------------------------
C:\j2sdk1.4.2_14\bin>javac D:\WS\DSDProjects\Utility\rda2\rda2.java
D:\WS\DSDProjects\Utility\rda2\rda2.java:21: cannot resolve symbol
symbol : class Rda2Server
location: class rda2.rda2
Rda2Server serverLib = Rda2Server.INSTANCE;
^
D:\WS\DSDProjects\Utility\rda2\rda2.java:21: cannot resolve symbol
symbol : variable Rda2Server
location: class rda2.rda2
Rda2Server serverLib = Rda2Server.INSTANCE;
^
2 errors
Since your source file is Rda2Server.java, that is the expected class
name, not "rda2".
You also probably need to implement StdCallLibrary. If the method
names are decorated (e.g. Connect@16), then you will need to supply a
StdCallFunctionMapper to the library init options so that the java
names are properly converted to what the DLL is supplying.