Using FalconView in Jacob

  • Mark Freedman
    Mark Freedman

    I have previous experience creating an application in .NET to talk to Falcon View over COM. I am now trying to do this in java. I am using the JACOB library to communicate with FalconView.

    The COM stuff is executed by what is essentially reflection -- getting objects by name/ID and executing methods by identifying them with literal strings.

    So far, all I'm able to do is get an ActiveX instance of FalconView, which seems to execute the fvw.exe and display it. I am unsure how to get a reference to an IMap, ILayer, ILayer3, etc. In .NET, I set up a container that explicitly instantiated a MapClass?, LayerClass?, Layer3Class, etc.

    I am unsure how to do this with my COM library in Java and FalconView. It seems that it's looking for a clsid givent he progid I'm giving it. I've tried different things such as fvw.MapClass?, MapClass?, fvw.IMap, IMap, etc., but with no luck. Any suggestions on how to proceed (even using a different java com library, or other solution) is suggested, but I'd really like to use falconview if possible.

    import com.jacob.activeX.ActiveXComponent;
    ActiveXComponent falconview = new ActiveXComponent("falconview");
    ActiveXComponent map = new ActiveXComponent("MapClass"); // fails here.

    It's also not clear to me if I need to include a fvw.dll that I created using tlbimp.exe from the fvw.tlb file. I think this is just to get compile time refernces to the FalconView classes. I'm actually not clear on how it works, since isn't the FalconView COM API in the GAC and can be pulled that way?

    Finally, is there a working example somewhere of actually using JACOB? This sourceforge page references this discussion forum to get started. A set of discussion topics and issues is not a getting started guide. The documentaiton that comes with the dowlnoad package touches on some points of using JACOB, but not a definite example. I've found an Excel Interop example, but even that was out of date and had to change a few method calls.

  • clay_shooter

    Download the sources zip file. It contains integration tests /examples

  • Mark Freedman
    Mark Freedman

    Thanks. I see the examples, but do not see an example of a java class implementing a COM interface for callback features. is this possible to do callbacks?

  • MarkBeard

    I am unsure what you mean by a callback in this instance. My understanding of that methodology is that you can 'register' an instance of class with another object and methods will be called on that 'registered' class instance;. This is not the sort of methodology that JACOB adopts as far as I understand it.

    With JACOB you will be manipulating an instance of an application for want of a better term. You start the application and then 'ask' it for a handle to a method or a property which you can then call or set or get. As an example, this is how you could open a document in Word;

    public void openDoc(String docName) {
    Dispatch disp = null;
    Variant var = null;

    // First get a Dispatch object referencing the Documents collection - for
    // collections, think of ArrayLists of objects.
    var = Dispatch.get(this.oleComponent, "Documents");
    disp = var.getDispatch();

    // Now call the Open method on the Documents collection Dispatch object
    // to both open the file and add it to the collection. It would be possible
    // to open a series of files and access each from the Documents collection
    // but for this example, it is simpler to store a reference to the
    // active document in a private instance variable.
    var =, "Open", docName);
    this.activeDoc = var.getDispatch();

    In simple terms, as the comments suggest, it asks the application for a handle to the Documents collection. Once it has that, then it can call the Open method which is defined on the Documents collection.

    You will need to do likewise with the application you are trying to automate. The first step will be to get your hands on the object model for the application to find out what the names of the various members are. Once you have that, you will have to work through them in a hierarchical fashion - stepping from parent to child where necessary - to accomplish your task.

    Hope this helps, if not, just post to the list.

  • Mark Freedman
    Mark Freedman

    I understand how to invoke methods using Dispatch on the FalconView application. The COM interface is two-way though. When something happense in FalconView (such as clicking the map, closing the application, etc.), the application will call back to the object/program that it initially registers with.

    In my C# application, the RegisterWithMapServer() call is made, with the third argument being "this", and "this" class implements interfaces defined by the COM API, specifically ICallback, ICallback2. I do not know this translates to JACOB.