pf » Getting Java System Properties in ColdFusion
Getting Java System Properties in ColdFusion

A while back I wrote some CFML code to dump the Java System Properties, the code went something like this:
<cfset system = CreateObject("java", "java.lang.System")>
<!--- properties is a java.util.Properties object --->
<cfset properties = system.getProperties()>
<!--- propNames is a java.util.Enumeration --->
<cfset propNames = properties.propertyNames()>
<cfoutput>
<cfloop condition="propNames.hasMoreElements()">
<cfset propName = propNames.nextElement()>
<strong>#propName#</strong> = #system.getProperty(propName)#<br />
</cfloop>
</cfoutput>
That works (the code didn't work in until CFMX 6.1, see this post), but I realized today as I wanted to display the results in a table much like the way CFDUMP works - that a java.util.Properties object is a java.util.Dictionary, and a ColdFusion structure is a Dictionary so I can probably CFDUMP a Properties object. And you can infact CFDUMP a Properties object or any Hashtable, and it will output the values in a table just like a structure. So now I can dump the java system properties in a table with only two lines of code:
<cfset system = CreateObject("java", "java.lang.System")>
<cfdump var="#system.getProperties()#">
<cfdump var="#CreateObject("java", "java.lang.System").getProperties()#">
This works however the changes don't stay around. Is there anyway to edit and get CF to see the changes? Thanks D
- Mastering CFQUERYPARAM
- Google Code Search for ColdFusion
- Speaking at CFUNITED 2008
- Getting ColdFusion SQL Statements from SQL Server Trace
- CFSCRIPT Cheatsheet
- 3 New Image Effects for ColdFusion 8
- Googlebot to Submit Web Forms
- ColdFusion 8 Update 1 Fixes some Image Processing Quirks
RSS
add to del.icio.us
Pete Freitag is a software engineer, and web developer located in










