Lets you create and use Java objects, and, by extension, EJB objects.
CreateObject("Java", class)
Parameter |
Description |
---|---|
class |
Required. A Java class |
To call Java CFXs or Java objects, ColdFusion uses a JVM embedded in the process. The loading, location, and settings for the JVM are configurable in the ColdFusion Administrator pages.
Any Java class available in the class path specified in the ColdFusion Administrator can be loaded and used from ColdFusion with the CreateObject
function.
Use the following steps to access Java methods and fields:
CreateObject
or cfobject to load the class.
<cfset ret = myObj.init(arg1, arg2)>
Calling a public method on the object without first calling the "init" method results in an implicit call to the default constructor. Arguments and return values can be any Java type (simple, arrays, objects). If strings are passed as arguments, ColdFusion does the conversions, but not if they are received as return values.
Overloaded methods are supported if the number of arguments is different. Future enhancements will let you use cast functions that to allow method signatures to be built more accurately.