CreateObject

The CreateObject function takes different arguments depending on the value of the first argument:

CreateObject('com', class, context, serverName)
CreateObject('component', component-name)
CreateObject('corba', context, class, locale)
CreateObject('java', class)
CreateObject('webservice', urltowsdl, [, portname])

Warning

In Lucee 5, this function has been deprecated in favour of the new object() syntax (reference needed). In line with our committment to CFML, this function will never be dropped from the language and you are safe to use it going forward.

CreateObject( type [, classname [, context [, delimiterOrVersion ] ] ] )

Returns: any

Argument Description
type
string, required

one of the following:

  • com: for loading a com Object
  • java: for loading a java object
  • webservice: for loading a remote webservice
  • component: for loading a Component

Alias: componentType

classname
string, optional

the usage of this argument depend on type defined with argument "type":

  • com: Component ProgID for the object to invoke.
  • java: java class to load
  • webservice: WSDL url to call
  • component: The CFC name; corresponds to the name of the file that defines the component

Alias: component, class

context
object, optional

the usage of this argument depend on type defined with argument "type":

  • com: not used (ignored)
  • java: classpath used to load the defined class, this can be a list of multiple paths (directories containing class files or jar files)
  • webservice: a struct containing the following optional keys (username,password,proxyServer,proxyPort,proxyUser,proxyPassword)
  • component: not used (ignored)

Alias: bundleName, name, webservice, Assembly, WSPortName, thirdarg

delimiterOrVersion
object, optional

the usage of this argument depend on type defined with argument "type":

  • java: delimiter used for the classpath (default comma) or bundle version when the previous argument was a bundle name
  • webservice: not used (ignored)
  • component: not used (ignored)
  • com: not used (ignored)

Alias: delimiter, version, bundleVersion

Examples

writeDump(label:"CreateObject in java", var:createObject('java','java.util.HashMap'));
writeDump(label:"CreateObject with init()", var:createObject('java',"java.lang.StringBuffer").init());

See also