Access ActiveX dll from Java using JNI
843829Oct 12 2004 — edited Oct 14 2004Greetings my fellow java comrades!
I have an ActiveX dl. It's written in C within the .net framework and was deployed to me as an ActiveX.dll. I have gone through the java jni tutorial and would like to use the same methodology to access the dll if it can be done.
If I understand it correctly, I have to create a java file, create a header file which I know how to do. However, since I'm not writing the implementation and creating a DLL- I presume that my implementation wouldn�t know where my header file is. Does the DLL need to know this? I know the name of the dll and where it lives and I have a help file that tells me all the methods and properties of the ActiveX dll but there wasn�t anything on how to go about accessing it in Java.
It also doesn't give me any clue as to how to instantiate the objects it uses to perform its tasks. The vendor included a Visual Basic example which showed the two main objects that it created, namely a license and a tool. They showed the declarations of these objects as below:
Public SDLIC As New SureDataToolkit.License
Public SDTK As New SureDataToolkit.Tool
Then in the form load it has:
Dim rc As Long
rc = SDLIC.StartManager()
I�m wondering at this point is how do the same type of thing in java (i.e.instantiate these License and Toolkit objects)? I understand the theory whereby any methods I wish to use I have to declare as native and then I can access them. But what about constructors for the objects it uses?
I did try running a simple example where I wrote a java file like this (note: the String key and String Uni parameters in the declaration are optional):
public class TrueDataJava {
static {
System.loadLibrary("SureDataToolkit");
}
public native long StartManager();
public static void main(String[] args){
TrueDataJava td = new TrueDataJava();
long rc;
rc = td.StartManager();
}
}
However, I would think that this wouldn�t work since loading the library doesn�t automatically create a constructor for a license object.
The above java code does compile and I can create an h file from it but then this brings me to my earlier question which was about the DLL needing to have access to the header file.
I do realize that there may be third party things I can get that would make accessing components easier but for various reasons I'd rather go the JNI or some other java-based route.
I think a wrapper may be the way to go but I've looked up some stuff on it and I didn't see anything that was relevant to my situation.
If anyone could point me in the right direction, I'd appreciate it.