Determining Machine Name Using Java

Often when you are developing in a team environment you will be using the same code base checked in and out of a source control repository (SVN, CVS etc). Sometimes you may have problems with developers having a different machine configuration than you do when these settings are stored as variables in a project config file.

One way we do things at Daemon is:

<cfset machineName=createObject("java", "").localhost.getHostName() />
<cfswitch expression="#machinename#">
    <cfcase value="sharmo">
        <cfset myVar = "test" />

This way each developer can script his or her own machine specific configuration in a case statement and not have a problem when checking into source control because everyone’s config is in the same file. Of course you may have problems if developers are in remote locations and have the same machine name

At Daemon the <defaultcase> is reserved for production settings only for safety.