To create Java stub files for COM objects:
Configure your system as follows:
1
Ensure that a JDK (Java Development Kit) is correctly installed, including proper
a
configuration of the CLASSPATH and the command prompt PATH variable.
Add CF_root\lib\jintegra.jar to your CLASSPATH.
b
Make a new directory for the Java stub files; for example:
2
mkdir C:\src\outlookXP
This directory can be temporary. You add files from the directory to a ColdFusion JAR file.
Run the CF_root\Jintegra\bin\com2java.exe program from a command line or the Windows
3
Start Menu. A window appears.
If a COM class implements multiple interfaces that define methods with the same names,
a
click the Options button and clear the Implement interfaces that may conflict option. The
generated Java stub classes do not implement the additional, conflicting, interfaces. You can
still access the interfaces using the getAsXXX method that is generated. See the generated
comments in the Java files.
Click on the
b
Select your COM object's Type Library or DLL. For Microsoft Outlook in Windows XP, it
c
is normally Program Files\Microsoft Office\Office10\MSOUTL.OLB.
Enter a package name (for example, outlookXP) in the Java package field in the com2java
d
dialog box. This package will contain all the classes for the Java stubs for the COM object.
Note: Macromedia uses a package name that starts with coldfusion.runtime.com.com2java for
the packages that contain the preinstalled Java stubs for Microsoft Excel, Microsoft Word, and
Microsoft Access. For example, the name for the package containing the Microsoft Word XP
Java stub classes is coldfusion.runtime.com.com2java.wordXP. This package name hierarchy
results in the wordXP classes having a path inside the msapps.jar file of coldfusion\runtime\
com\com2java\wordXP\className.class. Although this naming convention is not necessary,
consider using a similar package naming convention for clarity, if you use many COM objects.
Click the Generate Proxies button to display the File browser. Select the directory you
e
created in step 2, and click the file browser OK button to generate the stub files.
Click Close to close the com2java.exe utility.
f
The files generated in your directory include the following:
A Java interface and proxy class for each COM interface
A Java class for each COM class
A Java interface for each ENUM (a set of constant definitions)
Compile your Java code. In a command prompt, do the following:
4
Make the directory that contains the Java stubs (in this example, C:\src\outlookXP) your
a
working directory.
Enter the following line:
b
javac -J-mx100m -J-ms100m *.java
The compiler switches ensure that you have enough memory to compile all the necessary
files.
Note: If you did not put jintegra.jar on your CLASSPATH in step 1b, add the switch
-classpath:/cf_root/lib/jintegra.jar
installed, to the command.
772
Chapter 34: Integrating COM and CORBA Objects in CFML Applications
button.
Select
, where
is the directory where ColdFusion is
cf_root
Need help?
Do you have a question about the COLDFUSION MX 61-DEVELOPING COLDFUSION MX and is the answer not in the manual?
Questions and answers