Posts in Category "Java"

Making Your ColdFusion and Java Applications More Platform Independent (Part III)

Making Your ColdFusion and Java Applications More Platform Independent (Part III)

Two years ago (has it really been that long?!), I made a couple of posts about how to make your ColdFusion and Java applications more platform independent. The first post covered the importance of case consistency, and the second talked about not hard-coding path separators since they are different on different platforms. Well, all this time later, I actually have a third piece of advice: don’t hard-code new line characters.

I’m switching my development environment over from OS X to Windows (I haven’t used Windows consistently in many years, so I figured it was time to give it a try again), and while trying to get MXNA running locally, I came across a bug that I’d never seen in development (on OS X) or on production (Linux). The problem was this line of code:

<cfset blArray = listToArray(blacklist, chr(10))/>

The code is trying to convert a line-separated list into an array. On OS X and Linux, it works fine since the new line character is "line feed", or chr(10), or \n, but on Windows, the code didn’t work because a new line is "line feed" and "carriage return", or chr(10) & chr(13), or \n and \r. So rather than ever having to worry about this again, I used a little Java trick to make the code run in any environment. Now it looks like this:

<cfset blArray = listToArray(blacklist, createObject("java", "java.lang.System").getProperty("line.separator"))/>

Even with a language like Java (and hence, ColdFusion), if you want your code to be truly platform independent, it takes a little work. The good news is that once that was fixed, MXNA was up and running in my development environment perfectly.

How to Snoop on ColdFusion Data Types

Last week, I made a couple of posts about ColdFusion Arrays, and how they are actually java.util.Vectors, which means that you can convert them to Java arrays by calling toArray(). How did I figure that out? I didn’t ask the ColdFusion engineers. That’s cheating. The first thing I did was find out what type of class we are actually dealing with when we have a reference to an array. The Java object “Object” (which all objects extend) has a method called getClass() which returns the runtime class of an object. Calling toString() on the class (or simply the act of outputting it, which automatically calls toString()) will reveal the class name:

Continue reading…

Passing ColdFusion Arrays to Java

There were some comments on my weblog yesterday about using Java to sort ColdFusion arrays. The only problem is that you can’t pass ColdFusion arrays into Java where Java is expecting an Array. Why? Because ColdFusion arrays aren’t Java Arrays. They are, in fact, java.util.Vectors. Fortunately, it is easy to get an Array from a java.util.Vector. The following code demonstrates how to turn a ColdFusion array into a Java Array, and how to use Java to sort it:

Continue reading…

Flash as an Alternative to JSP and Applets

In honor of JavaOne, I wrote a DevNet article on integrating Macromedia Flash and Java. It’s pretty high-level (there are no code examples), but it pretty thoroughly discusses the capabilities of Flash and Flash Remoting, and the advantages of integrating Flash with Java. It also points to plenty of resources to help you get started. If this is something that you have considered, you might want to check it out.

ColdFusion MX Achieves “Java Verified” Status

Check out this story on Yahoo:

Macromedia ColdFusion MX Now ‘Java Verified’ for Portability Across J2EE Application Servers

An excerpt from the article:

Macromedia today announced that Macromedia(R) ColdFusion(R) MX has achieved “Java Verified” status under the Sun Microsystems Java Verification Program. The Java Verification Program is designed to identify enterprise applications developed with Java 2 Platform, Enterprise Edition (J2EE) technology that are intended to be portable across different implementations of J2EE.

You can all officially start thinking of yourselves as Java developers now!

TheServerSide Features Talk By Macromedia Software Architect

TheServerSide.com is featuring a talk by Sean Neville, the JCP Executive Committee representative for Macromedia and Flash Remoting software architect. From TheServerSide’s site:

Sean talks about Rich Internet Applications (RIAs), how they can be used to aggregate the business tier and enterprise applications using the client and looks at architectural approaches and technologies used for designing RIAs. He discusses how the J2EE Petstore was implemented in Flash, how the Flash Remoting product enables interoperability between J2EE and rich clients, and examines why vendors are trying to attract a new ‘VB-style’ group of developers. He also looks at changes that need to occur in the industry for RIAs to become mainstream.

Check it out here:

http://www.theserverside.com/events/index.jsp

Tons of New ColdFusion Content on DevNet

Macromedia just published several very high-quality ColdFusion (with a little Java thrown in) articles on DevNet:

Advanced ColdFusion: Simplicity Is Just the Start of It
Ben Forta
http://www.macromedia.com/devnet/logged_in/bforta_advcf.html

Building ColdFusion MX and J2EE Hybrid Applications
Drew Falkman
http://www.macromedia.com/devnet/mx/coldfusion/j2ee/articles/hybrid.html

Controlling Database Transactions in ColdFusion MX
Simon Horwith
http://www.macromedia.com/devnet/mx/coldfusion/articles/cftransaction.html

Improving Performance of Rich Internet Applications with Flash Communication Server MX
Giacomo ‘Peldi’ Guilizzoni
http://www.macromedia.com/devnet/mx/flashcom/articles/improving_ria.html

Building an Object-Oriented User Interface in ColdFusion MX
Dave Friedel
http://www.macromedia.com/devnet/mx/coldfusion/articles/oo_interface.html

Caching in ColdFusion
Matt Boles
http://www.macromedia.com/devnet/mx/coldfusion/articles/cfcaching.html

How Equals Works in Java

I saw some confusion about this matter on a list this morning, so I thought I’d clarify things here:

Continue reading…

Java Weblogs

I would like to get a good collection of Java weblogs posted here and aggregated into MXNA. Anybody have any favorites?

CFMX for J2EE License Transfer Program Extended

Anyone interested in going from ColdFusion Server to CFMX for J2EE should check this out. From Macromedia’s website:

“For a limited time, Macromedia ColdFusion Server Enterprise customers can transfer their licenses to ColdFusion MX for J2EE and receive up to a 30% discount through the Macromedia Volume License Program (MVLP).

Now, ColdFusion Server 4.5 (and later) Enterprise Edition (English version) customers can begin developing, deploying, and migrating their ColdFusion applications on their preferred J2EE application server at a significant savings.”

Offer good through 6/31/2003. Details here:
http://www.macromedia.com/software/coldfusion/j2ee/special/license_transfer/