The following example exports a simple IDL object that has no properties or methods and demonstrates the configuration necessary to initialize a COM or Java client application to use the exported object. First, create the IDL source object.

  1. Create a file named helloworld__define.pro (within your IDL path) containing the following code:
  2. FUNCTION helloworld::INIT
     
      RETURN, 1
     
    END
     
    PRO helloworld__define
     
      struct = {helloworld, $
      dummy:0b $ ; dummy structure field, not a property
      }
       
    END

    This is the source object definition file that you will export using the Export Bridge Assistant.

  3. Open the Assistant by entering IDLEXBR_ASSISTANT at the command line. See one of the following:

COM Wrapper Object Generation and Use


The following example exports and uses the helloworld object in a simple Visual Basic .NET console application. After creating the object definition file and launching the Assistant as described in Wrapper Generation Example, complete the following steps.

  1. Select to create a COM export object by selecting File > New Project > COM and browse to select the helloworld__define.pro file. Click Open to load the file into the Export Assistant.
  2. The top-level project entry in the left-hand tree panel is selected by default.
  3. There is no need to modify the default properties shown in the right-hand property panel, but you can enter different values if desired. Select the tree view item listed in the left column to configure the related properties in the right column.

    Tree View Item

    Parameter Configuration

    IDL Export Bridge Project

    Accept the default value or make changes as desired:

    • Output classname
    • Process name
    • Output directory

    helloworld

    Drawable object equals False

    For this simple example, the source object has no properties or methods, so none are exported.

    Note: See Specifying Information for Exporting for details on configuring export values.

  4. Save the project by selecting File > Save project. Accept the default name and location or make changes as desired.
  5. Build the export object by selecting Build > Build object. The Build log panel shows the results of the build process. For a nondrawable object, .tlb and .dll files (named based on the object name) are created in the Output directory.
  6. Register the .dll using regsvr32 helloworld.dll. See COM Registration Requirements for details if needed.
  7. Create a new Visual Basic .NET console application and add a reference to the COM library named helloworldLib 1.0 Type Library. Select Project > Add Reference, and click on the COM tab. Select the helloworld.dll and click OK.
  8. Replace the default module code with the following text:
  9. Imports helloworldLib
    Module Module1
     
      Dim oHello As New helloworldLib.helloworldClass
       
      Sub Main()
      Try
      oHello.CreateObject(0, 0, 0)
      Catch ex As Exception
      Console.WriteLine(oHello.GetLastError())
      Return
      End Try
      AddHandler oHello.OnIDLOutput, AddressOf evOutput
      oHello.ExecuteString("Print, 'Hello World'")
      End Sub
       
      Sub evOutput(ByVal ss As String)
      Console.WriteLine(ss)
      End Sub
       
    End Module

    In this example, the stock ExecuteString method is used to print the hello world message. By adding a handler for the OnIDLOutput method, the console application is able to capture and output the information that would typically be printed to the Output window of IDL. After building the solution and starting without debugging, the console window appears with the output messages.

Java Wrapper Object Generation and Use


The following example exports and uses the helloworld object in a simple Java application. After creating the object definition file and launching the Assistant as described in Wrapper Generation Example, complete the following steps.

  1. Select to create a Java export object by selecting File > New Project > Java and browse to select the helloworld__define.pro file. Click Open to load the file into the Export Assistant.
  2. The top-level project entry in the left-hand tree panel is selected by default.
  3. There is no need to modify the default properties shown in the right-hand property panel, but you can enter different values if desired. Select the tree view item listed in the left column to configure the related properties in the right column.

    Tree View Item

    Parameter Configuration

    IDL Export Bridge Project

    Accept the default value or make changes:

    • Output classname
    • Process name
    • Output directory (paths in later parts of this example assume this field equals the main IDL installation directory, which is typically C:\ITT\IDLxx on Windows)

    helloworld

    Drawable object equals False

    For this simple example, the source object has no properties or methods, so none are exported.

    Note: See Specifying Information for Exporting for details on configuring export values.

  4. Save the project by selecting File > Save project. Accept the default name and location or make changes as desired.
  5. Build the export object by selecting Build > Build object. The Build log panel shows the results of the build process. A subdirectory, named helloworld (based on the object name), contains the .java and .class files, and is located in the Output directory.
  6. Create a file named helloworld_example.java that contains the following code and save the file in the helloworld directory.
  7. package helloworld;
    import com.idl.javaidl.*;
    public class helloworld_example extends helloworld implements JIDLOutputListener
    {
      private helloworld hwObj;
       
      // Constructor
      public helloworld_example()
      {
      hwObj = new helloworld();
      hwObj.createObject();
      hwObj.addIDLOutputListener(this);
      hwObj.executeString("print, 'Hello World'");
      }
       
      // implement JIDLOutputListener
      public void IDLoutput(JIDLObjectI obj, String sMessage)
      {
      System.out.println("IDL: "+sMessage);
      }
       
      public static void main(String[] argv)
      {
      helloworld_example example = new helloworld_example();
      }
    }

    Note: By default, the Assistant generates a package so any Java routine using an exported wrapper object must include the package name. The second statement, import com.idl.javaidl.*; is also required.

  8. Select to create a Java export object by selecting File > New Project > Java listener is registered to retrieve the IDL output.

The wrapper is compiled and run using the commands below:

Windows Commands to Build and Run the Client

The following commands build and run this Java wrapper example on Windows.

  1. To compile and run the Java routine, open the Windows Command window by selecting Start > Run and enter cmd in the textbox.
  2. Use the cd command to change to the directory containing the helloworld directory. For a default Windows installation, the command would be similar to the following:
  3. cd C:\ITT\IDL63
  4. Reference the classpath of javaidlb.jar in the compile statement. Enter the following commands (each as a single line), replacing IDL_DIR with the IDL installation directory, for example ITT\IDL63:
  5. javac -classpath ".;IDL_DIR\resource\bridges\export\java\javaidlb.jar" helloworld\helloworld_example.java
    java -classpath ".;IDL_DIR\resource\bridges\export\java\javaidlb.jar" helloworld.helloworld_example

    In both commands, the . (period) character includes the current directory in the classpath.

    The first command uses javac to compile the example client. The path to the helloworld_example.java file is specified using a backslash character as a directory separator.

    The second command uses java to run the example client. The final argument specifies the package path to the helloworld_example class file. Note that a . (period) character is used as a separator in the package path. The final argument to the second command intentionally omits the suffix.

    After compiling and running the project, the output message will appear in the command window.

    UNIX Commands to Build and Run the Client

    The following commands build and run this Java wrapper example on UNIX:

    source IDL_DIR/bin/bridge_setup
    javac helloworld/helloworld_example.java
    java helloworld.helloworld_example

    Note: See Java Requirements for more information on the bridge_setup file.

    The source command adds the necessary directories to the dynamic library path and the classpath.

    The second command uses javac to compile the example client. The third command uses java to run the example client. The final argument specifies the package path to the helloworld_example. class file. Note that a . (period) character is used as a separator in the package path. The final argument to the second command intentionally omits the suffix.

After compiling and running the project, the output message will appear.