Sunday, June 14, 2009

JKstat, meet JavaFX

One of the announcements out of CommunityOne was the availability of JavaFX for Solaris and OpenSolaris - if you're lucky enough to be running on x86, anyway.

So the first thing that occurred to me was - could I use JavaFX to make a graphical front-end to JKstat?

(And the same thought occurred to Ben Rockwood as well, who asked me how easy it would be and pushed the thought from idle fancy to a must try, especially after I glibly said - "sure, dead easy".)



So the above image is jcpustate using the JKstat core api rendered with JavaFX. Of itself, it's nothing fancy, but it's served its purpose: I've got a rudimentary understanding of JavaFX out of it; I've worked out how to integrate JKstat amd JavaFX; and this validates that the JKstat core api does its job.

You can now download JKstat 0.29. Look in the jkstatfx directory, the source code for the above example is JCpuStateFX.fx.

I had a couple of issues getting this to work. I found I had to put the jni shared library (libkstat_jni.so) directly into the right javafx lib directory - setting LD_LIBRARY_PATH didn't seem to work. The other was that JavaFX doesn't natively support either java Collections or Generics. It clearly understands them - because it tracks the types of the objects in my Collections correctly (and it doesn't understand how to cast objects back toi the right type either). I ended up having to use the toarray(T[] a) method to create a Sequence of the right type.

I have to say that this wasn't the feature I had originally planned for this version of JKstat. I've been working on an interactive chart builder so you're not limited to the fixed and limited set of charts that JKstat creates on its own, but that will have to wait a while for the next release.

5 comments:

Anonymous said...

Super kool!

thebestseller said...

THX for sharing

The Bestseller

Nerd Progre said...

Here´s your next step: turning it into a Widget using the WidgetFX libs

http://learnjavafx.typepad.com/weblog/2009/01/create-widgets-in-javafx-with-newlyreleased-widgetfx-10.html

I'd like to dive into JavaFX as well.

However, I´m turned off by the OO nature of Java. When I was a child, M$ Basic twisted by brain and now the OO paradigm makes my head ache.

So, how about a "JavaFX tutorial for Bash programmers". Something procedural-oriented.

Or perhaps a "for real dummies" guide to JavaFX? The few tutorials I´ve seen are really geared towards the Java crowd, they start saying "see how easy it is" and then two lines later they can´t contain themselves and say "and you can call all java standard methods like this and that"... and there goes my understanding.

Sorry, I have a short attention span. :)

FC

Nerd Progre said...

Another question that might be of interest for you: how about docking/minimizing a javafx app to the systray (in winxp) or gnome launch bar *or whatever the #### they call it).

I had hopes of JavaFX using JDIC (Java Desktop Integration components) but I read somewhere that JDIC cannot be called from JavaFX :(

https://jdic.dev.java.net/

FC
PS: where's the source code for your tool? :)

Maija said...

Hi Peter,

The Product Reviews team at Sun has identified you as a leading, respected blogger in the OpenSolaris/Solaris community. Because of your recognized expertise and influence, we would like to talk with you regarding your opinion on OpenSolaris 2009.06.

This discussion will be two-part. First, we would like to engage in an e-mail Q&A interview to garner your perspective on what's new and exciting with the latest 2009.06 release. Then, we will follow up with a scheduled 5-10 minute podcast in Sun News or similar Sun Radio channel to discuss select questions covered in the Q&A in addition to other aspects of OpenSolaris you would like to discuss. We will conduct and record the podcast over the phone.

Highlights from both discussions will be featured in the Reviews Interactive blog. The Reviews Interactive blog is one of Sun's most popular blogs, and receives an average of 2,885 unique visitors per month. We will link to your blog from the posting and also give you the embed code for the podcast player, which you can in turn use on your own blog.

Please let me know if you are interested in this opportunity and I will e-mail you a Q&A and schedule the podcast at your convenience. We are very excited to interact directly with key bloggers in the OpenSolaris community and hope to speak with you soon.

Sorry to leave this note here in the comments, but I can't find your e-mail address. You can contact me at maijaliisa.burkert(at)sun.com

Kind regards,

Maijaliisa Burkert
Sun Product Reviews Team