Because the methods and syntax are similar, if you are familiar with creating CFXs using C++ you will be productive creating CFXs in Java almost immediately. Even if you have never used the C++ based API, you will find that the Java implementation is extremely easy to learn and work with.
Before you begin developing a CFX tag in Java, you may want to study sample CFX tags. The Java source files for the examples can be found in the examples
subdirectory of the main installation directory. The example tags are:
HelloColdFusion
- Prints a personalized greeting. Demonstrates the minimal implementation required to create a CFX.
ZipBrowser
- Retrieves the contents of a zip archive. Demonstrates generating a ColdFusion query and returning it to the calling page.
ServerDateTime
- Retrieves the date and time from a network server. Demonstrates attribute validation, using numeric attributes, and setting variables within the calling page.
OutputQuery
- Outputs a ColdFusion query in an HTML table. Demonstrates handling a ColdFusion query as input, throwing exceptions, and generating dynamic output.
HelloWorldGraphic
- Generates a "Hello World!" graphic in JPEG format. Demonstrates how to dynamically create and return graphics from a Java CFX.
You can use a wide range of Java development environments to build Java CFXs, including the Java Development Kit which you can download from Sun at
http://www.javasoft.com/products/jdk/1.2/index.html
Although you can use just the basic JDK, it is highly recommended that you use one of the commercial Java IDEs that provide an integrated environment for development, debugging, project management, and access to documentation. If you don't already have a Java development environment, we recommend that you try Symantec Visual Café, for which a 30 day free trial is available at
http://www.symantec.com/domain/cafe/vcafe30.html
To configure your development environment to build Java CFXs, you need to make sure that the supporting classes are visible to your Java compiler. These classes are located in the classes\cfx.jar
archive. The full path is <coldfusioninstalldir>/Java/classes Consult your Java development tool's documentation to determine how to configure the compiler class path for your particular environment.
The classes
directory created by the ColdFusion setup program serves two purposes:
com.allaire.cfx
package located in the cfx.jar
archive.
Allaire strongly recommends that when you create new Java CFXs, you develop and deploy them within the classes
directory. Following this guideline will dramatically simplify your development, debugging, and testing processes.
Once you are finished with development and testing, you can then deploy your Java CFX anywhere on the class path visible to the ColdFusion embedded JVM. See "Java Customization and Configuration" for more details on customizing the class path.