Java Platform, Enterprise Edition

Java EE Journal

Subscribe to Java EE Journal: eMailAlertsEmail Alerts newslettersWeekly Newsletters
Get Java EE Journal: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn

J2EE Journal Authors: Jeremy Geelan, Zakia Bouachraoui, Douglas Lyon, Stackify Blog, APM Blog

Related Topics: Open BlueDragon Developer's Journal, ColdFusion on Ulitzer, Java EE Journal

BlueDragon: Article

ColdFusion Everywhere PART 1

Create applications that run on the Web, from CD, or on the desktop

Think about the last time you bought a car. Did you walk around the vehicle, look under the hood and sit in the driver's seat to get a feel for it? You probably took it for a test-drive before making the final decision. If you're a developer producing the next "killer app," it's only reasonable for your customers to want to test-drive your application as well. Have you ever wanted to demo your application but thought...

  • It's too difficult to put together a general-purpose demo.
  • Even if you did publish a "live" demo site, it would be open to wrong-headed visitors entering offensive data, corrupting the demo for others.
  • If you don't allow data entry, you limit the effectiveness of the demo.
  • You could allow users to download your application (in some protected time-limited format), but they would need to install it and all the prerequisite programs (CFML server, database server, application server, Web server). They would also have to configure the application, populate the database, etc., etc., etc. This could take hours (or days).
  • This is a daunting proposition even for the technically capable - who are likely not the people you want to see your demo. (If potential customers had to put together a Lexus before taking it for a test drive, they'd buy a BMW...)
Ideally, potential customers can experiment with your application at the time and place they choose, using their own data - with no unnecessary activities to deter or distract them, and no need to have access to the Internet.

What if you could deliver your application into the hands of customers in a package they could just double-click and run?

Well, you can! With readily available building blocks you can put together a self-contained package that holds your application and everything needed to run it on any platform you support. Your application appears as an icon on the desktop. You double-click and run...that's it! Nothing gets in the way!

In this article we'll show you a way to package and deploy your CF applications that is different from anything you've done before - making your application available as a single download (zip) file, or burning it onto a CD or DVD. If your application doesn't need to write files or update a database, it can be run directly from the CD. The objective is to enable you to run your CF application everywhere (the Web, a desktop, or CD) - we call the concept "CFEverywhere."

Examples of CFEverywhere Applications

CF has been used (almost) exclusively to develop applications for Web (and intranet) sites. With CFEverywhere, you are no longer limited to the Web dynamic. You can take advantage of the power of CF to write desktop applications.

Let's look at some examples of how you can use CFEverywhere today with current CF products.

A Downloadable Trial Application
This is the scenario discussed earlier - you have a Web application that you want to give to potential customers to "try before you buy." Here customers run your Web application with full read/write database and file capabilities on their desktops.

A Web Site On a CD
A company maintains a Web site containing a catalog of thousands of items in hundreds of categories. To promote their site the company makes CDs of the entire site, which it hands out to potential customers at an annual trade show.

The Web site exists as a database-driven series of CF templates. Without CFEverywhere, it takes days of tedious, painstaking (and expensive) effort to convert the site to thousands of interlinked static HTML pages that can be accessed from a CD. Some Web site capabilities, such as searching and sorting, are not possible in the static version. With CFEverywhere, the Web site (CF templates and database) is copied intact to the CD along with the other components necessary to run CFEverywhere.

The time and expense of the conversion to static pages is eliminated. The user experience is enhanced because the CFEverywhere version contains all of the searching and sorting capabilities that exist on the Web site - in fact, we have duplicated the actual Web site onto the CD.

A Combination Offline/Online Application
There is a class of applications that can be used in a combination of ways. Some sections of the application do not require access to the Internet and run quite happily on the desktop using local files and data. Other sections require connection to the Web site and synchronization with the corporate database.

Consider this scenario: a manager updates a local copy of employee appraisals while off on retreat at a mountain cabin (with no access to the Internet). Later, upon returning to the real world, the manager connects to the corporate Web site and applies all the local updates to the corporate database.

There are many corporate activities that could follow the same pattern of offline data entry batched for online data update/cutover: price changes, new product catalogs, inventory counts, etc.

For example, a mail-order company with a large seasonal catalog sends a promotional CD to potential customers. Customers browse the catalog at their convenience selecting items to order: gift cards, shipping addresses, wrapping paper, etc. This is done over several days or weeks. The program is run directly from the CD, but the information is saved in a file on the customer's hard disk. When customers are ready to order, they click a button and the application connects to the vendor's Web site, uploads the order, and displays any "specials" not in the catalog. Truly, customers shop at their convenience - not governed by whether the Internet is available (or performing poorly because of traffic congestion).

Portfolio Piece
The Web is ever-changing. You may have written Web sites or applications that have been taken in-house and/or have been extended by other developers. Or, your implementation of the site was so dazzling that the company was purchased by another and for whatever reason, you can't point to these Web sites as examples of your work.

With CFEverywhere, you can maintain an archive of all the CF sites and applications you have developed, and create a "portfolio" CD for potential customers.

CF Desktop (non-Web) Applications
Traditionally, CF has been used to develop Web applications. However, many developers use CF as a quick, powerful solution for doing some non Web-related tasks such as reformatting and populating a database, statistical/design analysis of a database; application prototyping, and ad hoc report generation.

With CFEverywhere, you can actually develop applications specifically for the desktop. Use your imagination. Once you realize that you don't (necessarily) need a Web site to take advantage of the power of CF, a world of possibilities opens:

  • A CF application can be a low-cost alternative to writing a desktop application in Java or C. This is especially true when the programming resources are limited and there is a large backlog of high(er) priority applications. A CF solution could be implemented to provide immediate results (and benefits) until a more rigorous solution can be implemented in the other language.
  • Or, maybe the requirement is for a one-time report or analysis that is due yesterday - where CF is the only way to get it done. While a browser implementation of a user interface may not be ideal for a desktop application, it is likely to be easier and less expensive to implement than a custom UI written by other means. Arguably, the browser UI will be more familiar (and comfortable) for most users than a custom UI.
  • You could write a control panel/monitor that displays the status of all components of the system.
  • You can write desktop applications that invoke Web-related facilities (e-mail, messaging, Web services) to provide desktop functions.
    - For example, the control panel/monitor application could use e-mail to send an SMS text message to a technician's cellphone, alerting him that the system needs attention.
    - Or, a desktop application could invoke a Web service to obtain stock prices to update your portfolio.
    - Or, send an e-mail to a CF desktop application that reboots the database server. Since the CF application runs on the desktop, it can (with authentication) have complete access to the OS facilities, file system, scripting languages, etc.
For example, you could write a CF application that watches a certain folder in a user's system. Whenever an image file is added to the folder, the CF application executes a shell script to invoke Photoshop to copy and resize the image into a database or photo album (or product catalog).

These are only a few ideas of how CFEverywhere can deliver applications - on the desktop! Certainly, these are quite different from "typical" CF Web applications! Hopefully, we've whet your appetite for CFEverywhere. In the next section we will begin to assemble the CFEverywhere system to deliver your application.

CFEverywhere Components

To achieve CFEverywhere, the following components are required: a J2EE server, a Web server, a database server, a CFML runtime and, of course, our application code. The J2EE server acts as a "container" for the runtime that executes the application code. Let's go through the process of choosing the appropriate components and performing their configuration. In this section, we will configure and install the Web/J2EE servers and the CFML runtime. (Note: This process is cross-platform and works for Windows and Mac OS X/Linux.) Figure 1 shows the CFEverywhere directory structure.

There are several J2EE servers available on the market today. Some are open source while others are commercial offerings. You may have heard of these J2EE server products: JBoss AS, BEA WebLogic, and Macromedia JRun. For our purposes we will use a server called Jetty from Mort Bay Consulting. Jetty was selected for the following reasons:

  • It's free
  • It includes a Web server
  • The license allows for commercial use and distribution
  • It's easy to install and configure
  • It has a small footprint and is embeddable
We also need to select a CFML runtime. In addition to Macromedia CFMX/J2EE, there is a product called BlueDragon 6.1/J2EE from New Atlanta. Of these products, only BlueDragon can be used with CFEverywhere due to licensing restrictions. New Atlanta has a very friendly OEM/partner program that allows for distribution of BlueDragon with your CF application. Contact them and they'll be happy to discuss the details of their program. Macromedia currently has no such program but we understand the next release of CFMX (code name Blackstone) may address this issue and make it suitable for a CFEverywhere application. We'll have to wait and see.

Before we proceed further, make sure your system has a Java runtime installed. At a command prompt (or terminal on Mac OS X) type:

java -version

You should see something like "java version 1.4.2_05." If you get an error, you don't have Java installed/configured on your system. Go to to download the Java runtime. Note that although the latest version of Java is 1.5 (a k a 5.0) most products are not yet supported for that version. Your best bet is to install a Java runtime version 1.4.x. Also, create a folder for the project and call it "CFEverywhere." For example:

  • D:\CFEverywhere (for Windows)
  • /Applications/CFEverywhere (for Mac OS X)
Download Jetty from the Jetty Web site, The latest stable version is 5.1.0 so you should download, which includes demo files and other extras. Extract the zip file into your CFEverywhere folder. It will expand as jetty-5.1.0, but to save some typing at the command line, rename the folder server. Create a new folder underneath the CFEverywhere/server directory called wwwroot. This folder will serve as the Web root for our CFML application. To test your Jetty installation, open a command line and change to the server directory

cd d:\CFEverywhere\server

Then start the server

java -jar start.jar etc/demo.xml

This will start Jetty; you can test it by pointing your Web browser to http://localhost:8080/. You should see a version of the Jetty Web site. If you don"t, you may have a port conflict with port 8080. Check for any other servers listening on that port and shut them down.

By launching the Jetty demo, you noticed that Jetty is configured with XML files. We need to create a configuration file for our CFEverywhere application. Copy the demo.xml to a file called CFEverywhere.xml. Open the file in any text editor and change the root context to point to the /CFEverywhere/server/wwwroot folder. It should look like the following:

  <!-- Add root context web applications. -->
  <Call name="addWebApplication">
    <Arg><SystemProperty name="jetty.home" default="."/>/wwwroot</Arg>
    <Set name="defaultsDescriptor">org/mortbay/jetty/servlet/webdefault.xml</Set>

(The complete file can be downloaded from Let's create a couple of test pages. Create a simple index.html page that displays "Hello World" and put it in the wwwroot directory. Next, create a file CFEverywhere.cfm with this code:

<cfset message = "Hello World! -- CFEverywhere" />
<cfdump var=#cgi#>

Now launch Jetty with:

java -jar start.jar etc/CFEverywhere.xml

This time when you point your browser to http://localhost:8080/, you should see "Hello World." Great! We're able to serve up HTML files but we really want to run our CFML page. Enter BlueDragon...

Go to the New Atlanta Web site,, and download the latest BlueDragon 6.1 for J2EE ( Extract the archive to a convenient location like your desktop but don't put it in the CFEverywhere folder. Copy the contents of the BlueDragon_webapp_61 folder to your CFEverywhere/server/wwwroot folder (just the contents, not the entire folder). I hope you didn't blink because you might have missed it. You just deployed BlueDragon/J2EE on Jetty! Now launch Jetty again like we did previously. Browse to http://localhost:8080/CFEverywhere.cfm and you should see "Hello World! -- CFEverywhere" as well as a dump of the CGI scope variables.

That's it! You've just completed your first CFEverywhere application. Try transferring the CFEverywhere files to another computer (even on a different platform) and see if you can get it to run. If the "Hello World! -- CFEverywhere" application doesn't inspire you, come back for the other articles in this series where we'll:

  • Show you how to deploy a typical CF application that includes a database
  • Make a clickable application that can run on Mac OS X and Windows
  • Burn it to CD-ROM

More Stories By Phil Cruz

Phil Cruz is a Macromedia Certified Advanced ColdFusion developer and has over 12 years of experience in the computing industry. He is responsible for, a community site for the Mach-II framework. As a micro-ISV, he created Tracking Tools, an easy-to-use bug tracking application built with Mach-II (

More Stories By Dick Applebaum

Dick Applebaum has been involved with computers (and their predecessors) since 1956, including 16 years with IBM. Dick and two partners opened the fifth retail computer store in Silicon Valley in 1978. Eleven years later, he sold the stores and didn?t touch a computer for seven years (when he discovered the Web). Since 1997, Dick has been developing applications using ColdFusion.

Comments (4)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.