Low-Level Java/COM Integration
 In this topic

*New Features

 

Java & Native Code    JNativeNext
Low-Level Java/COM Integration     JNative Next

 


Introduction

The Microsoft Virtual Machine for Java (Microsoft VM) supports integration between Java and the Component Object Model (COM), which is the protocol underlying the Microsoft® ActiveX® platform, Automation, and Object Linking and Embedding (OLE). With Java/COM integration, you can give your Java program access to any software component that supports COM, including thousands of ActiveX controls and Automation objects.

Java/COM integration is available at two levels, corresponding to the dual-interface nature of the ActiveX Automation model. At the highest level, ActiveX controls are converted directly to JavaBeans components (Beans) by the Microsoft VM, and Beans are converted to ActiveX controls. The type mapping for parameters is done automatically in this case, based on the standard IDispatch types used by all ActiveX controls to communicate with their containers.

On the other hand, since ActiveX controls are dual-interface objects, they can also be accessed by their vtable methods. This is how C programs typically access these controls and what is referred to as low-level Java/COM integration in this article. This mode of access is particularly useful when you need to marshal data types that are not handled by IDispatch between Java and COM objects.

New Features

If you have used earlier versions of the SDK for Java and Visual J++, you might be interested to learn about several new features that can make it easier (or more efficient) to accomplish certain tasks that involve COM objects. These tasks previously required the use of javatlb, which has been replaced by the jactivex tool (called jcom in previous releases):

  • Hosting an ActiveX control within a Java component.

    You can use the jactivex tool to expose an ActiveX control as a JavaBeans component (a Bean). This tool also generates listener interfaces for catching events.

  • Exposing a JavaBeans component as an ActiveX control.

    The Microsoft VM now does this for you automatically. Every Java object is, by default, exposed as an ActiveX control whose IDispatch interface is generated using JavaBeans introspection on the Java class. For more information, see the article on ActiveX/Beans Integration.

  • Calling a DLL from Java

    Previously this required wrapping the DLL inside a COM interface for the purpose of calling the DLL from Java. You can now make direct calls to a DLL function using Microsoft® J/Direct™. To learn how to use J/Direct, see the About J/Direct article.

The following topics are available in this article:
Using a COM Object From Java
Implementing COM Objects
Type Mappings Between Java and COM
Handling COM Errors in Java
COM Programming in Java and C++ Compared
Apartment Model and Threading Issues

You can find more information about COM in the Component Object Model Specification that is included in the Win32 Software Development Kit.

Top © 1998 Microsoft Corporation. All rights reserved. Terms of use.