Published:
Warning: This blog entry was written two or more years ago. Therefore, it may contain broken links, out-dated or misleading content, or information that is just plain wrong. Please read on with caution.
Its not mentioned often but while most people run normal cfml on their sites, it is actually possible to precompile the cfml into java bytecode and run that. At this point you are asking why would I want to do that.
Improve Performance
By compiling to javabyte code you save coldfusion from having to compile the source code the first time that page is loaded. This improves performance especially if you have a large number of templates and restart you server.
Protect IP
Secondly by deploying java bytecode instead of plain text cfml you can protect my intellectual property. This can be quite important as a contract term, for example you might specify that source code is only turned over on final payment. Or maybe someone has licenced the use of a component and you want to make it harder for it to be passed on etc.
Introducing the Compiler
Adobe makes precompiling our source code easy with a handly utility in the coldfusion bin directory called cfcompile.bat . This file is located at {coldfusion-install-dir}\bin\cfcompile.bat .
To run this file open a cmd prompt window, navigate to the directory where cfcompile.bat is located and run the following command.
cfcompile -deploy [webroot] [sitedir] [outputdir]
For example say you have a webroot folder at c:\htdocs with a site named myblog located inside the webroot at c:\htdocs\myblog and you want to compile this code to an output directory of c:\htdocs\myblogcompiled . You would run the following command.
cfcompile -deploy c:\htdocs c:\htdocs\myblog c:\htdocs\myblog\compiled
Note that I do NOT put quotes around the directory paths.
Reader Comments