While I don't know a lot about using java objects in CF, I know more about java itself. A static method is called on the class itself, not the object that gets instantiated. This is useful for tracking the number of times an object gets instantiated and obviously for other reasons as well.
So, for static methods, you do not need to call the constructor. However, static methods only have access to static member data so there is that limitation. Since in CF it seems that you have to create a java object to use it, there may not be a way to call static methods. However, like I said I don't know a lot about using java objects in CF Kris Jones wrote: > Calling on all you CF-Java-knowledgeable folks out there. I'm trying > to follow some of the examples in the iText tutorial, and I've hit a > mental wall. > > When trying to instance a file output stream, the java example I see > looks like this: > > Document document = new Document(); > try { > PdfWriter writer = PdfWriter.getInstance(document, new > FileOutputStream("Destinations.pdf")); > [blah blah blah...] > > Obviously, that's not going to fly in a cfscript block. > How would you write this in CF? Something like: > > <cfscript> > document = createobject("java", "com.lowagie.text.Document"); > finalOutPutFile = "C:\testpdf.pdf"; > myPDF = createObject("java","java.io.FileOutputStream").init(finalOutPutFile); > fso= createobject("java","com.lowagie.text.pdf.PdfWriter"); > try { > writer = createobject("java",fso.getInstance(document, myPDF)); > [blah blah blah...] > </cfscript> > > Or would it the actual fso be created like: > fso = > createobject("java","com.lowagie.text.pdf.PdfWriter).getInstance(document, > myPDF); > > What's confusing me is the static PdfWriter.getInstance method. In CF, > I thought I had to call an init() method on the class to get back an > object, but if there's a static method (not a constructor per se), how > would I do this? Forgive this horrid example--I'm sure I've got this > all jumbled around. My ultimate goal is to add destinations and > outlines (bookmarks) to a new PDF file as it gets created via > concatenated PDFs. > > Thanks, > Kris > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:251424 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4