FX Experience Has Gone Read-Only

I've been maintaining FX Experience for a really long time now, and I love hearing from people who enjoy my weekly links roundup. One thing I've noticed recently is that maintaining two sites (FX Experience and JonathanGiles.net) takes more time than ideal, and splits the audience up. Therefore, FX Experience will become read-only for new blog posts, but weekly posts will continue to be published on JonathanGiles.net. If you follow @FXExperience on Twitter, I suggest you also follow @JonathanGiles. This is not the end - just a consolidation of my online presence to make my life a little easier!

tl;dr: Follow me on Twitter and check for the latest news on JonathanGiles.net.

BrickBreaker running on a Raspberry PI

BrickBreaker running on a Raspberry PI

Today Oracle has released the first JavaSE 8 + JavaFX Developer Preview. This is really exciting for anybody who’s wanted to try out the $35 Raspberry PI ARM mini-computer (and I do mean mini!). Incidentally, anybody who picks one up really needs to get the Pi-Bow enclosure for the PI — I got one yesterday and highly recommend it!

JavaSE is a HotSpot based VM, so it is really quite zippy. I did some timing calculations on my PI this morning based on the prime number test provided in this Raspberry PI Java forum posting. Yes, there is a new Java category on the Raspberry PI forums, do visit and leave your experiences there :-). Anyway, I ran both Java and GCC version 4.6.3 with -O2 performance optimization enabled.

Test Real User Sys
JavaSE 8 (build 1.8.0-ea-b36e) 0m7.830s 0m4.970s 0m2.840s
GCC 4.6.3 (Debian 4.6.3-12+rpi1) 0m7.716s 0m4.990s 0m2.700s
GCC 4.6.3 (Debian 4.6.3-12+rpi1) -O2 0m6.361s 0m3.940s 0m2.400s

I find the results really impressive, because basically the difference seen between Java and native is just due to the startup costs. Which means that Java is a really great choice for developing applications that will run on the Raspberry PI. Java also represents (to my knowledge) the first VM stack to optimize for hard float on ARM v6.

I couldn’t help myself though, I cranked up the test to find all prime numbers below 50,000 to see if the startup costs in fact are the difference between the JVM and native code. Below are the results. As you can see, HotSpot is faster than native code!

Test Real User Sys
JavaSE 8 (build 1.8.0-ea-b36e) 1m37.808s 1m25.570s 0m12.000s
GCC 4.6.3 (Debian 4.6.3-12+rpi1) 2m18.875s 2m7.390s 0m11.1300s
GCC 4.6.3 (Debian 4.6.3-12+rpi1) -O2 1m42.166s 1m31.206s 0m10.580s

I wrote a quick JavaFX application this morning and tried it out. A couple things to make sure you note!

  • jfxrt.jar is not on the classpath by default (yet). So be sure to include it!
  • -Djavafx.platform=eglfb must be specified. If not, it won’t run.
  • Ahem. There appears to be no way to kill an FX app, unless you can SSH into your box or switch to another terminal. Or have your app make sure it has an exit button. But then, when playing BrickBreaker, who’d ever want to stop?

None of the flags used in javaFX on the command line are “public API” and may go away in the future, but this particular flag is likely to be around for a while. It lets you choose which version of glass to run with. On Raspberry PI, right now, the only option is eglfb (which makes you wonder why we require you to specify it on the command line. There are some questions that we just shouldn’t ask ;-)). Basically EGLFB runs OpenGL on the frame buffer directly, meaning that it wants to own the entire screen. This is great for Kiosks and media centers and such, but not so good for normal X11 usage. Hopefully the X11 usage shows up sometime soon, but in the meantime, JavaFX will own the display.

You should go read the developer preview documentation and also Stephen Chin’s blog on PI. JFokus has a Raspberry PI hands on lab, which is already fully booked, but I’m betting you can get Simon Ritter to give you some material if you want to try at home :-).

Have fun hacking over the holidays!