Issue calling method in ActiveX Control (.ocx) via Java - 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).

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.

Related

What does one do regarding applets now that Chrome doesn't support Java?

Without thinking, I created an entire program in Java and began designing a website to use this applet. All it does is create image in a certain way but there is a bit more code (classifications and default values/images) that I just felt was easiest to do with Java. Now I have a Java app and HTML CSS and JavaScript that I can't seem to do much with.
I have thought of 2 ideas (below) but I don't know what the general alternative is to applets nowadays.
I have a spare PC I may use and just alter my applet to run the back-end of a server-based site instead, but I am hesitant to use my own IP and bandwidth for something like this. Also, this app doesn't even need access to the internet so this just seems like way overkill.
I could just release the .jar, but I plan on expanding the available options. I also told people that this website was coming. I'd like to be able to just update the website.
I don't really plan on writing my program in another language. This took me time to make. If there is no way to work Java into my site, I may just abandon the project altogether.
I am mainly concerned with Chrome for this problem.
Edit: I would like to use GitHub as my host, just in case this helps at all.
You can run anything you want on the server, including java programs. So
you could run the image creation program in the server and present the
resulting image using a standard img tag.

Swing Works different on different Platform

I have made a Screen Recorder using Java Swing and Xuggler 5.4. I have developed it in Windows 8 64 bit. It's working excellent for Windows. But at client side on Linux's environment , nothing is working. I have searched thoroughly but not getting any solutions. I have checked this thread , but it didn't work for me.
Then I tried to create simple Transparent window in Linux but it's also not working. I was not able to click through the Resizeable Panel. I have used the same JRE version (1.7) for both. Have I miss understood Java's Cross Platform Support as far as Swing is concerned?
Please Give Me Some Advice...
I have always found logging to be the best debugging tool at your disposal! Many a times, java debuggers take you into APIs where you need not go every time. Logging values of your variables, and generic 'I have reached till this point' statements make life a lot easier.
So, I suppose you have ample logging done in your code. That could give you clues on what's happening on your client's system.
Are the right environment variables set? Are they pointing to the correct Java versions you need.
If there are some specific Screen capturing requirements(plugins / modules / API) your code has, are they available on the Linux m/c?
Like #MadProgrammer said, in the end, Java has to talk with the native graphics APIs to render your screen.
I would try to debug it in this way -
Check whether my main screen loads or no(by disabling the screen capture functions for a while).
if not, dig deeper.
Check whether all necessary components for capturing screen(audio and video) are available.
Check whether the code is being run with appropriate permissions to control the h/w devices you may need.

Java and HID Communication

I'm looking to write a Linux/Windows/Mac Java HID controller for a simple wireless HID interface device. I've tinkered around with the USB4Java LibUsb library to no avail, and I've been steered in the direction of the JavaHIDAPI.
Unfortunately for me, I really have no idea what I'm doing beyond a pretty decent higher level programming skill set (C#/VB.Net), and switching over to this is killing me.
The directions that I found said that I would first need to compile the HIDAPI library found here. It said it would build something called hidapi-jni.dll (which it didn't).
Anyway, I think this is where I need to go since the HID does nothing but simply sends and receives signals to and from a wireless control (and responds to signals received).
Is there any step-by-step tutorial for using the JavaHIDAPI for this? Or is there a better library? (I noticed that this is a bit... dated).
I tried myself with the following:
static{ System.loadLibrary("hidapi"); }
.
.
.
public static void main(string[] Args) throws . . . {
ClassPathLibraryLoader.loadNativeHIDLibrary();
HIDDevice dev = HIDManager.getInstance().openById(VEND_ID, PROD_ID, null);
.
.
.
}
The issue into which I am running is that (besides the fact that the HIDAPI doesnt seem to be building into HIDAPI-jni.dll) is that the HIDManager.openById(. . .) always returns null. Also, I moved the hidapi.dll that was built into the C:...\Java...\bin directory... or something, I'm sure it's right because there wasn't any unsatisfied link error. It's really frustrating because there doesn't seem to be any newbies guide to Java and HID anywhere.
What am I doing wrong here?
I'm a bit late to answer this question, but I've written a library called hid4java that might solve your problem.
It's based on Java Native Access (JNA) which is a lot simpler than faffing about with complex JNI incantations.
I had to write it because javahidapi is out of date and the underlying signal11/hidapi code has moved on considerably. The older versions of the hidapi library had problems on OS X with attach/detach events which have now been fixed so an upgrade is necessary.
Also I found it impossible to claim a USB HID device through usb4java on OS X so I ended up writing this library to solve that problem.
Hope it helps.
So the issue, I discovered, was with native libraries.
I was able to get the application to work by copying the .dll from the .jar file and referencing it, but more important, I'm going to rebuild the .java class file responsible for loading the library and add the
System.loadLibrary();
call. When the JavaHidApi ClassPathLibraryLoader.loadNativeHIDLibrary(); method is called it doesn't load the library upon successfully writing it out to the temp file which is mildly annoying. Doing this will eliminate the necessity for manually loading the library from a static location...
Thank you for pointing me in the correct direction.

just get the names of USB devices attached to a system?

Aren't there any system calls or OS specific functions that can be called by Java to get just the names of the USB devices attached?
I've seen probably 6-7 questions here only, but everyone mentions the C++ functions GetRawInputDeviceList() etc, and they are not cross-platform compliant. Either for Windows in C# or C++ or for Linux only.
But I'm working in Java. Also, this needs to be cross platform.
Atleast, it needs to be working for Windows,Linux and Mac. I can work with terminal/shell/command-prompt commands also. I guess I can run them with Java.
I've tried getFileSystemView and listRoots. But they give out names of all drives [dvd, hdd partitions,floppy etc].
I need to get only USB devices.
Please don't mention jUSB or JSR080. Why:
jUSB: access to USB devices currently requires that they be connected to a GNU/Linux host system
javax.usb: pre-alpha Windows implementation is not certified and requires a kernel driver.
usb4java: basically, it just implements JSR80 with little more abstraction, perhaps
Although to be honest I haven't tried libusb since it is in C++.
If you are going to mention APIs, mention completely tested and tried ones, that work across Linux,Windows and Mac.
If that wasn't the case, I wouldn't have put this question up. I've seen the mention of jUSB, javax.usb, etc on many other posts.
You can use the jUsb API, for Linux.
Or you could launch the terminal in Linux using the Process class, and run
ls -la /dev/disk/by-id/usb-* and catch the stdout to know the results.
For Windows, you can try this : How to find my USB flash drive's path with PowerShell
EDIT:
For Windows, another helpful utility is the devcon.exe.
For more info, check this.
EDIT 2:
For Mac, you could launch the terminal using the Process class, and run system_profiler SPUSBDataType
Yoy can try javahidapi. I think it some c/c++ code and JNI. Declarated linux, mac and windows support. I have tried it with linux (ok), with clean windows in virtual box (not ok, UnsatisfiedLinkError, i think some MSVS libs was missed). If you'll compile it from source, it should work, i belive.
here is example:
import com.codeminders.hidapi.HIDDeviceInfo;
import com.codeminders.hidapi.HIDManager;
public class TestHid {
public static void main(String[] args) throws Exception {
try {
com.codeminders.hidapi.ClassPathLibraryLoader.loadNativeHIDLibrary();
HIDManager hidManager = HIDManager.getInstance();
HIDDeviceInfo[] infos = hidManager.listDevices();
for (HIDDeviceInfo info : infos) {
System.out.println("info: " + info.toString());
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
EDIT
output shows only one plugged in usb device, genius laser mouse.
[grigory#gr testRSA]$ pwd
/home/grigory/testRSA/out/production/testRSA
[grigory#gr testRSA]$ whoami
grigory
[grigory#gr testRSA]$ java -cp ".:hidapi-1.1.jar" Test
libusb couldn't open USB device /dev/bus/usb/003/002: Permission denied.
libusb requires write access to USB device nodes.
info:HIDDeviceInfo [path=0003:0002:00, vendor_id=1112, product_id=58, serial_number=null, release_number=0, manufacturer_string=null, product_string=null, usage_page=0, usage=0, interface_number=0]
[grigory#gr testRSA]$ sudo java -cp ".:hidapi-1.1.jar" Test
[sudo] password for grigory:
info:HIDDeviceInfo [path=0003:0002:00, vendor_id=1112, product_id=58, serial_number=null, release_number=0, manufacturer_string=Genius, product_string=Laser Mouse, usage_page=0, usage=0, interface_number=0]
[grigory#gr testRSA]$
and for fresh Windows XP it isn't work (only one windows i can find. I haven't Visual Studio for compile lib from source):
E:\testRSA\out\production\testRSA>java -cp ".;hidapi-1.1.jar" -Djava.library.pat
h="e:\testRSA\out\production\testRSA" Test
Exception in thread "main" java.lang.UnsatisfiedLinkError: com.codeminders.hidap
i.HIDManager.init()V
at com.codeminders.hidapi.HIDManager.init(Native Method)
at com.codeminders.hidapi.HIDManager.<init>(HIDManager.java:53)
at com.codeminders.hidapi.HIDManager.getInstance(HIDManager.java:121)
at Test.main(Test.java:14)
Maybe things have improved since you first asked this question. I recently began exploring usb4java on the Mac, and it seems to work. There is example code available, both for the low-level (libusb-like) API, and the high-level (javax) API.
To list all USB-devices, look the examples.
I downloaded all libraries directly from usb4java.org and the examples from github. I did not manage to get the maven build working, but I could import the libraries and examples in Eclipse and run them all.
There are same native code included in usb4java, but the library wraps them all quite beautifully and hides all the messy details, only extracting and deploying the native code at demand.

Android Pros: How to wrap PayPal's MPL?

I have no Java experience and prefer Visual Basic; I've found a very nice translation IDE called Basic4android (www.basic4android.com). It works by interpreting a scripting language that's similar to Visual Basic and then using it to generate and compile native Java code. Rather ingenious, if you ask me. In fact I believe I found it from a reference here on StackOverflow.
I'm having some trouble wrapping PayPal's Mobile Payments Library:
www.x.com/community/ppx/xspaces/mobile/mep (scroll down for the HTML Tutorial)
I need to do it in a way that promotes the library's functionality so that B4A can in turn expose it to the Android device (emulator in this case). I've made some halting progress so far, but now I'm stuck on NullPointerExceptions occurring deep within the MPL.
The saga is pretty well described in a thread at their forum:
http://www.basic4ppc.com/forum/additional-libraries-official-updates/8819-looking-download-link.html
Here's my wrapper and the generated code—download here—as only licensed users may access downloads in that particular forum section.
The latest NullPointerException occurs a few calls down from the initWithAppID function. The JD-GUI decompiler reports an internal error when it gets to the com.paypal.android.b.b class, so it doesn't appear to be possible to know exactly what's going on down there.
I'm certain this can be done; I just need to know how to open the proper communication channel between the device and the MPL.
I'm new at Java and I'm new at Android. Quite a combination, wouldn't you say?
It turns out the problem is in the way PayPal bundles their resource files; non-Eclipse projects can't get at them.
More info on the original B4A thread.
Thanks,
Jeff
I think if you ask here about something that generates code for you, you won't be provided with any answers because you can't give any useful source code or something. Also, if you use something like this tool, you never know what it's generating. Also, you can't fix any occurring errors with the generated code... I could go on and on and on...
If you want to use Android the way it's supposed to be used, you'll need to learn Java and Android. If you are good with VB, this shouldn't be that hard. And this is what anyone is going to tell you.

Categories

Resources