I was recently working with some java libraries that looked to a system property for a configuration setting. The sample Java app that came with the library was setting the system property on the command line. Their windows .bat file and Linux shell script both launched the java app like this:

java.exe -cp .;package1.jar -Dcom.company.product.maxvalue=500 SampleApp

Note the -D option, that sets the java system property com.company.product.maxvalue to 500. If you are not familiar with java system properties – they are kind of like a global variable, accessible via any java code.

I didn’t want to have to edit my Jrun start up options and add the -D option on there. That option is not even possible for many ColdFusion users. But setting a system property via ColdFusion is actually very easy.

<cfset sys = createObject("java", "java.lang.System")>
<cfset sys.setProperty("com.company.product.maxvalue", 500)>

Reading a system property is equally simple:

<cfset sys = createObject("java", "java.lang.System")>
<cfoutput>#sys.getProperty("com.company.product.maxvalue")#</cfoutput>