English

How To: Call into custom COM components from Java

Summary

The ArcGIS Engine Java API provides Java proxy classes for ArcObjects COM components allowing users to use ArcObjects through the Java programming language.

It is sometimes useful to extend ArcGIS using custom COM components written in a COM compliant language like C++ or Visual Basic and to programmatically access the extensions through Java.

This can be useful in the following cases, among others:

1) Extending ArcGIS Server with custom COM components that make heavy use of fine-grained ArcObjects method calls.

Having a COM component on the ArcGIS Server tier perform the multiple fine-grained ArcObjects method calls leads to a performance boost as multiple round-trip calls from the web-tier to the ArcGIS Server over the network are replaced by a single call to the custom COM component, which in turn makes multiple in-process calls.

2) Integrating legacy or third party components written in a native, COM compliant language, into a GIS application. These components may offer functionality orthogonal to the GIS domain but may need to feature in the workflow of a GIS application, working alongside ArcObjects.

Procedure

The procedure that is taken depends on the version of ArcGIS that is being used. The instructions provided cover the cases for ArcGIS 9.1 and 9.2.

ArcGIS 9.2

In ArcGIS Engine 9.2, the Java-COM interop has been integrated into the ArcGIS runtime and explicit support has been added to the ArcGIS Java SDK to generate Java proxies for custom COM components authored in C++.

Java proxies for such ArcGIS extensions can be generated using the Proxy Generator tool (ARCGISHOME/java/tools/proxygen/Proxygen.exe)

Documentation on using ProxyGen is provided in the Java Developer Help.

A developer scenario has also been provided explaining the usage.

ArcGIS 9.1

Note:
The following procedure for ArcGIS 9.1 is provided for informational purposes only and is not a supported workflow and involves purchasing a third-party product.


In ArcGIS 9.1, the ArcGIS Java API included Java proxies for ArcObject components and a Java-COM interoperability bridge called J-Integra (version 2.3) from Intrinsyc Software. The arcobjects.jar provided Java proxy classes for ArcObject components, there was no explicit support for accessing custom ArcGIS extensions written using COM.

Accessing custom COM extensions from Java requires the use of J-Integra's COM2Java tool to create proxy classes. This is a third party tool and requires a license for J-Integra from Intrinsyc Software. The steps for generating Java proxies for custom COM components follow.

1. Install J-Integra on a Windows machine (the COM2Java tool is only available on Windows) following the instructions.
2. Build COM objects

2.1 Start with a DLL project generated via the ATL COM AppWizard in Visual Studio 6.
2.2 Insert a simple ATL object. Note the Prog ID for this object to be used later.
2.3 Extend this to incorporate any additional interfaces for this COM object. Add appropriate import statements for the .olb’s that will be used
2.4 Compile and generate the DLL library

3. Build proxies for the COM objects on the client side.

To consume the custom COM objects that generated above, the com2java tool provided by JIntegra can be used to generate client-side proxies. These proxies are generated in the form of Java classes that can be incorporated into the client code. Run “com2java” from the command line to bring up the UI. Specify the path to the .dll and the path to the folder where the proxies can be stored. An optional package name can also be specified.
[O-Image]
Open Settings->Options and ensure that the following properties are set/unset -
[O-Image]
The tool then prompts for appropriate mapping between .tlb’s or .olb’s and the corresponding Java package names
[O-Image]
[O-Image]

[O-Image]
Use the table below as a reference for values to be provided for these mappings
[O-Image]