javawiacom4j

Using COM objects with WIA and com4j in Java


I am a newbie in this and I wanted to ask if you could recommend me some articles, examples etc to start with communicating with scanner in java application
I am developing a module that should communicate with different scanners conected directly or in the local network... I would like WIA to start with and com4j..
thanks all for any advices :)

Edit: I came to some informations in this Com4j tutorial, that I need to generate some java type definitions from an ocx file.
If i had understand it, these generated classes will be my client to get the scanner using com4j. But what ocx/dll file shoud I use?
Anyone has idea?

Update 1: so I've managed to get the library to generate the wrapper classes, it was wiaaut.dll (Windows Image Acquisition Automation Library) and then via the ClassFactory I made an DeviceManager instance, but there are no devices in it...
How can I make the deviceManager to see the scanner on the local network?

Update 2: so i've discovered, that my HP LaserJet 2840 cant scan trough the network in win7 64 bit... now this question is answered, should I post the answer myself and set it to accepted, or close this Q other way? thanks


Solution

  • so, my HP LaserJet 2840 cant scan trough the network in win7 64 bit

    but the steps to use com objects like scanners or digital cameras in java are:

    1. download and install the oleviewer from MS Download center and in category Type Libraries, find the Microsoft Windows Image Acquisition Library or something similar and copy the location of the file (it should be System32 directory)
    2. then download them com4j jar file from com4j website and use the tlbimp.jar as shown here. It will generate the objects for you and now just use the ClassFactory to create the object to handle the com objects and go on with experimenting ;)

    PS: maybe now it is easy but I had hard times to learn this :)