cfjava

Provides support for writing Java code within ColdFusion.

  <cfjava handle="classInstance">

 cfjava(handle="classInstance");

This tag requires Adobe ColdFusion 2021 and up.  Not supported on Lucee, etc.

Attribute Reference

handle variableName
Required

The variable that holds the value of class instance of the Java code.

Links more information about cfjava

Examples
Sample code using the cfjava tag

<cfjava handle="nameInstance">
    public class Name {
        private String firstName;
        private String lastName;

        public Name(String firstName, String lastName) {
            this.firstName = firstName;
            this.lastName = lastName;
        }

        public String getFullName() {
            return firstName + " " + lastName;
        }
    }
</cfjava>
<cfset nameInstance.init("John", "Doe")>
<cfset fullName = nameInstance.getFullName()>
<cfoutput>#fullName#</cfoutput>

Expected Result: John Doe

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub