The CreateObject function can create a Java object, and, by extension, an EJB object.


A Java object.

Function syntax

CreateObject(type, class)





Type of object to create.

  • com
  • corba
  • java
  • component
  • webservice
    The default value of type is component.


A Java class name


Any Java class available in the class path that is specified in the ColdFusion Administrator can be loaded and used from ColdFusion with the CreateObject function.To access Java methods and fields:

  1. Call the CreateObject function or the cfobject tag to load the class.
  2. Use the initmethod, with appropriate arguments, to call an instance of the class. For example:

<cfset ret = myObj.init(arg1, arg2)>

Calling a public method on the object without first calling the "init" method invokes a static method. Arguments and return values can be any Java type (simple, array, object). If strings are passed as arguments, ColdFusion does the conversions; if strings are received as return values, ColdFusion does no conversion.Overloaded methods are supported if the number of arguments is different. Future enhancements will let you use cast functions that allow method signatures to be built more accurately.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy