Recently I’ve been working on a Flex project and have been doing some tinkering with Java. Both languages require you to compile source code in order to execute the target application. After doing some refactoring within the Flex application, it struck me just how much the compiler helps you to scoop up any mistakes that may have been made along the way.
For example, I could change a variable to be of a different class type and the compiler would then list all of the locations where any references to that variable became invalid. It’s then just a case of clicking through the errors in the Eclipse problem view and making any appropriate fixes.
I guess this is only helpful for small to medium refactorings. Refactoring on a larger scale you’d ideally want to use a refactoring tool which thankfully Java and Flex 3 have within Eclipse.
It got me thinking though. Seeing as there is no refactoring tool for ColdFusion, would compiling the source code before attempting to run an application, help with fixing bugs and trapping any mistakes that may have been made?
If you don’t already know, you can use the cfcompile utility to compile ColdFusion applications into java .class files. If errors are encountered within any source files, they are output in the form of stack traces and in the usual ColdFusion style of “Error x occurred in y file at z location”.
I decided to investigate whether I could make use of cfcompile through Eclipse. It’s actually quite easy, although not an ideal solution, which I’ll elaborate on later.
From the main menu bar choose:
Run :: External Tools :: External Tools
A new window should open listing the external tools that are currently configured in Eclipse. One of the options should be titled ‘program’. Right click on the icon and choose ‘new’.
Give the configuration a meaningful descriptive name like ‘Compile ColdFusion Code’. Then within the ‘location’ field, enter the full path to the cfcompile .bat or .sh script. For Mac and ‘nix users running the ColdFusion J2EE configuration, there’s some additional work in order to get CFCOMPILE working. Read all about it here.
Finally click the ‘Variables’ button. From the list of variables choose ${file_loc}. Click the ‘Apply’ button and everything should be configured and ready to go!
Select a project or an individual .cfm / .cfc file within your Eclipse resource navigator and from the toolbar area select the ‘Run External Tool’ icon, which looks like the image below. Then choose the ‘Compile ColdFusion Code’ option.

If everything works correctly, you should see Eclipse launch the console view. Within the console should be the compilation results. Any errors will appear in red.
As I mentioned earlier, all of this isn’t ideal. What would be nicer is if you could click through each error via the ‘Problems’ view.
What do people think? Would this make your ColdFusion application development and debugging easier in any way?