Search code examples
javaactivexjacob

Issue calling method in ActiveX Control (.ocx) via Java


My end goal is to get a JPG from a fingerprint scanner inside my Java application. I don't need to do any recognition or logins.

I have a Topaz IDGem LCD 1x5 signature pad / fingerprint scanner. The SDK they provide for the fingerprint scanner part of the device is called SigIDp1. The problem is that it is only available as an ActiveX control.

I know next to nothing about ActiveX. From my research, I seem to need a Java to COM bridge to interact with the ActiveX control through Java. The JACOB project seems to be the most well known. My problem is that I can't seem to make it work with this particular ActiveX control file.

My super advanced Java program looks like this:

import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;

public class JacobTest {

    public static void main(String[] args) {

        Dispatch test = new ActiveXComponent("SigIDp.SigIDp1");

        Dispatch.call(test, "CreateJpg");
    }
}

The problem is that when I try to create the new ActiveXComponent object, I get a com.jacob.com.ComFailException: Can’t co-create object error. According to this page, it looks like this has to do with the .ocx file not being properly registered. However, I can't use the referenced .NET tool (i.e. RegAsm.exe) to register the control because I get an error saying it's not a valid .NET assembly. And, when I use regsvr32.exe to register it, registration seems to succeed, but I still get the can't co-create error (I've tried the regsvr32.exe in System32 and in SysWOW64).

All that to say, I'm pretty stuck. I'm open to any suggestion that will help me achieve the end goal, even if it's start over with friendlier hardware (although I'm having trouble finding any fingerprint scanner with a free Java SDK).


Solution

  • For anyone else that stumbles upon this:

    It turns out that it was an architecture issue after all. The ActiveX control in question seems to only be available in 32 bit form. So, it didn't matter which version of regsvr32.exe I used to try to register it because (as far as I understand) an app running in a 64 bit JRE can't interact with a 32 bit ActiveX control.

    The "solution" for me was to use a 32 bit JRE for my project. It's not ideal, but at least I'm moving forward now.