Creating an instance of a nested Java class in ColdFusion

Im trying to create an instance: java.awt.geom.Point2D.Double in ColdFusion.

Point2D.Double is a nested class inside the abstract Point2D class. I 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")>that does not work, because Point2D is an abstract class, and there is no public constructor that you can invoke on PointClass.init(x,y).

Right now, I resorted to creating my own Point class, which wraps the Point2D.Double class so that I can create an instance in ColdFusion. I don't think this is perfect, and I'm looking for ideas on how to directly create the Point2D.Double class in ColdFusion.

I also use ColdFusion 8.

+3
source share
1 answer

Try:

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

For nested classes use $

+13
source

Source: https://habr.com/ru/post/1697729/


All Articles