Creating ActiveX Components in Java

This article has three sections:
This sample does not run as an applet. In the sample directory, there is a COM client for this COM component written in Java. The client is VBDRIVER.EXE. It is is written in Microsoft® Visual Basic® 4.0.

See the source code.


Overview of the sample

The COMCallingJava sample shows how to create and register an ActiveX component using Java and Visual J++.

About the server

CEuclid is a simple Automation server written in Java. It is has a single method GCD that calculates the greatest common factor (denominator) of two numbers. The input numbers are the parameters to GCD.

About the sample

This sample shows how to create an ActiveX (COM) component in Java. This component can be used from any Automation controller. Microsoft® Visual Basic® is an example of an Automation controller.

COMCallingJava includes a test driver for the CEuclid class. The test driver VBDriver was written using VB 4.0. The code for VBDriver is in the VBDRIVER subdirectory.

Return to the top of this article.


How to use this sample

To run the COMCallingJava sample:

  1. Create a type library describing the COM component.
    See
    Creating a Type Library.
  2. Create a Java interface for the COM component.
    See Creating a Java Interface for a COM component.
  3. Compile CEuclid from euclid.java.
    Open the COMCallingJava project file.
    From the Build menu in Developer Studio, choose Build.
  4. Register the CEuclid class file as a COM component.
    See Registering a Java COM Component.
  5. In Explorer, double-click the test driver VBDRIVER.EXE.
    See the VBDRIVER subdirectory for the source code for the driver.
Return to the top of this article.

Files in this sample

This sample includes the following files.

Project files:

Support files: Return to the
top of this article.