Setting COM Classes

See Also

Exposing a class as a COM class is a way of creating powerful and reusable applications. By selecting a class as a COM class, the class and its public methods can be accessed from other applications and programming languages. The COM Classes tab of the <Project> Properties dialog box allows you to specify which public classes in your project should be exposed as COM classes. Once a class has been defined as a COM class, Visual J++ creates a type library for your project's COM classes so that it can be accessed by other applications and registered as a COM object in the system registry.

The COM Classes tab also allows you to use an existing type library to expose your project's classes or to create class templates for existing type libraries or embedded COM object ActiveX controls. A COM template allows you to use Java source code to implement COM components that are described in type libraries or pre-existing COM components. If you have a type library or COM component that you wish to implement using Java, you can select the type library or COM component from the list and Visual J++ will build the template code in your project. You can then implement each of the methods provided by the templates, and compile to create a COM component.

To make a class in your project a COM class

  1. On the Project menu, click <Project> Properties (where <Project> is the name of the project that is currently selected in the Project Explorer).

    The <Project> Properties dialog box appears.

  2. Select the COM Classes tab.

Note   Any settings made in the COM Classes tab of the <Project> Properties dialog box are not affected by changes in the build configuration settings in the Configuration list.

  1. In the COM Classes tab, click Automatically generate Type Library.

  2. Place a check mark next to the class you wish to make a COM class.

  3. By default, Visual J++ creates a type library file based on the name of the project. To change this and other information related to the type library, such as the library name, description, help file, and help context ID, click Options. This displays the Type Library Options dialog box where you can modify the information for the type library.

To use an existing type library

  1. On the COM Classes tab, click Use existing Type Library and then click Select.

    The COM Templates dialog box appears.

  2. From the list of Installed COM Components, locate and place a check mark next to the type library you wish to use. If the type library is not registered in your system registry, you can click Browse to select the type library you wish to use.

  3. Click OK.

    Visual J++ creates a package directory in your project directory and also creates the template classes in the new package directory.