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:
- Create a type library describing the COM component.
See Creating a Type Library.
- Create a Java interface for the COM component.
See Creating a Java Interface for a COM component.
- Compile CEuclid from euclid.java.
Open the COMCallingJava project file.
From the Build menu in Developer Studio, choose Build.
Copy the resulting class to the <windows>\Java\Lib directory.
- Register the CEuclid class file as a COM component.
See Registering a Java COM Component.
- Copy MSMASK32.OCX to the <windows>\System directory.
Change directories to the <windows>\System directory.
Register the MSMASK32.OCX control using the REGSVR32.EXE tool
regsvr32.exe msmask32.ocx
- 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:
- euclid.java - the Java source code for the sample
- comcallingjava.dsw - the project workspace file
- comcallingjava.dsp - the project file
- euclid.odl - the ODL description of the COM component
Support files:
- registereuclid.bat - a batch file to register the CEuclid class as a COM component
- vbdriver.exe - a client for CEuclid written in Visual Basic
- msmask32.ocx - support file for vbdriver.exe
- comcallingjava.html - this read me file
- register.html - instructions for registering a COM component
- javatlb.html - instructions for creating a Java interface for COM components
- mytyplib.html - instructions for creating a type library
- <vbdriver> - the source for the Visual Basic client
Return to the
top of this article.