Creating an instance of a nested Java class in ColdFusion

coldfusion, java

Solution

Try with:

<cfset PointClass = createObject("java", "java.awt.geom.Point2D$Double")>

For nested classes, use `$`

Problem

I’m trying to create an instance of: java.awt.geom.Point2D.Double in ColdFusion. Point2D.Double is a nested class inside of the abstract class Point2D. I have tried to instantiate the class using: ``` <cfset PointClass = createObject("java", "java.awt.geom.Point2D.Double")> ``` This fails because ColdFusion cannot find the class. And `<cfset PointClass = createObject("java", "java.awt.geom.Point2D")>` which does not work because Point2D is an abstract class and there is not a public constructor on which you can call `PointClass.init(x,y)`. Right now, I’ve resorted to making my own Point class that wraps the Point2D.Double class so that I can instantiate it in ColdFusion. I don’t think this is ideal and am looking for ideas about how to directly create a Point2D.Double class in ColdFusion. I'm also using ColdFusion 8.

Original source