This post is archived and probably outdated.

Fighting JavaFX

2008-11-19 07:42:00

I recently wrote a few postings about great Sun stuff. The reason for that? - Well since joining Sun I get all the information about the things Sun does and there are tons of cool things, I enjoy OpenSolaris, especially DTrace and zfs (zfs snapshots!) - these are great pieces of technology. Ok, you can feel that OpenSolaris isn't finished yet, but it's a good step from a classic Unix to a quite usable system.

Now Sun is famous for another product family: Java. For me Java has always been a synonym for ugly and annoying applets and over-engineered "enterprise" applications which are close to being unusable. Being Sun I learned about a new technology for fighting the RIA wars against Microsoft's Silverlight and Adobe's Flex: JavaFX. After browsing a while over the different sites I found out that key part of JavaFX is a declarative scripting language for creating user-interfaces. That sounds quite cool - no annoying and over-verbose XML and no procedural coding for describing a GUI, but a syntax which looks quite sane for that. So I wanted to give it a shot. And that's where the trouble began ...

... on the downloads page I first read about a NetBeans plugin being featured, ok, great for getting started a GUI supporting me is a nice thing, I'm not soo much of a GUI guy, but yeah, let's try it, especially as in my previous experience NetBeans, unlike other IDEs, doesn't do too much wrong. On the download page they offered only a full bundle but no information how get the plugin stand alone, so I went to my NetBeans, I'm having NetBeans 6.5RC2 installed, opened the plugin manager and didn't find JavaFX. Sad. With the help of a search engine I found out that the plugin should be available there in the "Beta" repository. Double checked wasn't there. As I'm running a pre-release version of NetBeans I figured out that the probably don't offer the JavaFX plugin officially there and added the 6.1 Beta repository, and see: a JavaFX plugin was available there. So next step: Install it into NetBeans 6.5. Installation failed as some "webstart" plugin wasn't registered. Checked the bugs database: Known issue, fixed in the code repository, but not yet in a release. Bad luck.

Next step: Fetch the old version of NetBeans, 6.1, which I had still installed. Go to the plugin manager, select JavaFX, click install, which didn't work, again. This time the javafx sdk plugin was missing. Ok, enough of stupid GUIs let's go command line!

First step: Go to the downloads page and load the SDK. First barrier: Which operating system am I running? - Sorry neither MacOS nor Windows. I could offer Linux and OpenSolaris but no downloads for either of them. Checked using a search engine, I'm not the only one having that problem but there's a solution: Fetch the MacOS zip package unzip it, set $PATH and $JAVAFX_HOME and go.

Cool it's running - Wait, how do I know it's really running? Let's take some sample code an run it. Finding code is easy, there's plenty of stuff. On the different sites, oh these sites, that's another source of confusion, there's the openjavafx site, there's the javafx.com site and stuff on sun.com but mostly share the same text and link to each other... but ok, found some code, now how do I execute it. Reading the tutorial doesn't give any information. So I had to do more research. With a quite simple solution: Save the code to some file like foo.fx then run javafxc foo.fx now you get a .class file. Sounds like Java, so run java foo and get an error message, remember "hey it's JavaFX, use javafx as command," run javafx foo and hey - it really works!