12 CHAPTER 30 Extending ColdFusion with CFX
To compile your CFX, use javac on the command line to compile the HelloWorld.java file as
shown below, adjusting the paths to the
cfx.jar and HelloWorld.java files as appropriate for your
system:
javac -classpath c:\CFusionMX7\lib\cfx.jar HelloWorld.java
The cfx.jar file contains the com.allaire.cfx package, which defines the Request and Response
interfaces referred to in the skeletal snippet shown in the previous section (and in Listing 30.1). The
cfx.jar file is installed automatically to the CFusionMX7/lib folder when you install ColdFusion.
The compiler needs to be able to find this file in order to be able to compile the class; typically,
you provide the location using the
-classpath switch as shown above. Consult the Java SDK
documentation for the
javac utility for details on the -classpath switch.
NOTE
Depending on how your system is configured, you may also need to provide a full path to the javac executable, which is located in
the bin subfolder within the folder to which the Java SDK was installed.
After you compile the tag, a file named HelloWorld.class will appear in the same folder where the
HelloWorld.java file is located. Copy this file to the
WEB-INF/classes folder within ColdFusion’s
program root (typically
c:\CFusionMX7\wwwroot\WEB-INF\classes if you’re using a Windows server).
NOTE
I’m having you place the class file in the WEB-INF/classes folder because that is recommended by Macromedia as a good place
for CFX class files during testing and development. Once you have finished developing the tag, you can place the class on your pro-
duction servers in just about any location. The only caveat is that the class needs to be somewhere within the Class Path specified in
the Java and JVM page of the ColdFusion Administrator.
NOTE
The ColdFusion documentation also refers to the WEB-INF/classes folder as a good place to put your class files during devel-
opment. The documentation suggests that one of these folders (the
WEB-INF/classes folder or the CFusionMX7/lib
folder) is meant to ease development by eliminating the need to restart ColdFusion after a Java CFX has been recompiled.
If you want, you can tell javac to place the class file directly in the lib folder as it is being compiled.
As an example, I used the command shown below to compile the class (Figure 30.3). Of course, I
typed this all on one line, but it’s too long to print on one line in this book:
c:\jdk1.3.1-01\bin\javac c:\inetpub\wwwroot\ows_adv\30\HelloWorld.java
-classpath c:\CFusionMX7\lib\cfx.jar
-d c:\CfusionMX7\wwwroot\WEB-INF\classes -verbose
This command assumes that the Java SDK was installed to the c:\jdk1.3.1_01 folder, that you are
using the built-in Web server, that the
HelloWorld.java file is stored with the other listings for this
chapter (within the
ows_adv branch of the Web server document root), and that ColdFusion was
installed to the default c:\CFusionMX7 location. Make whatever path adjustments are necessary for
your system. You can leave off the
-verbose switch if you want; it just causes javac to display some
additional messages while it is compiling the class.
Commenti su questo manuale