Flex Data Services and Java JDKs
If you’re a newbie just starting on Flex Data Services 2.0 (FDS) and J2EE development, you will most likely go and download FDS from Adobe with the integrated JRun 4 application server immediately followed by a Java Development Kit (JDK) from Sun (if you don’t already have one).
And if you’re one to always have the latest and greatest or are just following the first link that you see on Sun’s webpage like any newbie would, you’ll probably grab a JDK targetting Java 1.5 and think that you can compile some of your own classes and go merrily along. Not quite so fast–you’ll actually need to tweak your JRun 4 installation if you plan on using the latest Java 1.5 JDK (it’s really pretty easy–see below the fold for more details). If, rather, you just want to get going right out of the box with the default installation, however, what you really want is the older Java 1.4.2 JDK.
This is probably old hat for experienced J2EE developers, especially those with their own toolchain and J2EE server already configured before installing FDS, but I ended up learning this the hard way working through Marcel Boucher’s My First Hibernate Enabled Flex Application tutorial on his blog. Everything worked fine up until I tested my client-side Flex application upon which I received a rather cryptic error complaining about a failed NetConnection. Replacing my files with Marcel’s fixed the problem–and I eventually narrowed it down to differences between his .class file and mine.
A closer reading of his blog shed some illumination on my misfortune, as I noted that my Java compiler was a different version than his. Marcel was using the 1.4.2_12, whereas I had the newer 1.5.0_09. Digging into my JRun 4 installation a bit more revealed that it comes out of the box with a Java 1.4.2 Runtime Environment as well. Thinking that it was a version mismatch, I recompiled my Java class again with the source and target versions specified as 1.4 and got a working example application.
Now, you’re probably wondering, what if I want to use the current Java 1.5 Runtime Environment with my JRun 4? All of my Java-slinging friends tell me it has all these new features and that’s where the action is at in the local bookstore’s computer aisle. Well, it’s actually not all that hard. All that’s needed is to go into your JRun 4 bin directory and change the java.home line to direct it to your own Java 1.5 installation.
This simple fix removes the need to specify source and target parameters when invoking the Java 1.5 compiler and allows you to follow along with all the latest and greatest in the Java world while starting out on your own Flex Data Services adventures.