The No.1 i-Technology Magazine in the World !
   
 

      ES no BS
This is a personal blog of Yakov Fain       My son's animations and music         No BS IT podcast      Америчка




Archives

««Sep 2010»»
SMTWTFS
    1
2
34
567891011
12131415161718
19202122232425
2627282930

RSS Feed








Subscribe to these blogs

Pet Store with JavaFX 1.0. Part 1.

posted Wednesday, 11 February 2009

I work for a company called Farata Systems. Laura is our office manager, and she doesn’t know Java. Everyone else does.  We work in the enterprise RIA space using Adobe Flex as a main development tool for creating all these Web pages connecting to the server side applications written in Java.

In December of 2008, Sun Microsystems has released the first version of a language for developing UI for RIA. I’ve been watching the evolution of JavaFX from its announcement at JavaOne 2007 till its release, but wasn’t able to find any demos that would prove that this extension of Java platform can be considered as a candidate for boring needs of enterprise applications. Watching demos like a bunch of balls moving inside a glass didn’t look too convincing to me.

We decided to contribute to Java community and invest some time and resources to figure out what JavaFX 1.0 is capable of. Most of the Java developers know what Pet Store application is. For many years this reference implementation has been used by Sun Microsystems as a part of Java BluePrints program for Java EE platform.

The current version of this application is described in the article called “Introducing the Java Pet Store 2.0 Application” that’s available at http://java.sun.com/developer/technicalArticles/J2EE/petstore/.

We re-used the existing back end of the Pet store, but performed a little facelift by replacing the UI developed with AJAX/JSP/JavaServer Faces with JavaFX 1.0.

I was working on this project with our senior Java developer Alex Litskevich who’s done lots of digging and research trying to find the best solutions whenever we would run into limitations of JavaFX.
The goal of this introductory article is to demo the JavaFX Pet Store. You can watch a quick prerecorded demo at this URL .

In the future, I’ll deploy this application in one of our public servers and will review the code. 

Last year, while attending a conference in India, I met an excellent Sun’s software engineer Greg Murray, one of the authors of the idea of Pet Store application.   Greg, I hope you’ll like this version of your pet store.

 

Flex, JavaFX, Silverlight…

I’ll be honest with you, during development of this application in the back of my mind I’ve been constantly comparing the way things are done in JavaFX with how I’d do the same with Adobe Flex.  
Simply put, today, Flex is a lot more productive than JavaFX.  But let’s remember that we are comparing products of versions 3 vs. version 1. If you know how to develop Swing applications, you might want to continue doing this rather than manually creating JavaFX 1.0 wrappers for Java code as we did in our Pet Store.

The biggest issue is that JavaFX 1.0 doesn’t include any UI component library that a Web developer needs. I’m not talking about data grids or tree views. Even such simple things as a hyperlink component aren’t there. I can’t think of any other reason but a trivial lack of time and limited human resources allocated by Sun for development of this new UI set.

Hopefully, Sun will release a JavaFX 2.0 in foreseeable future with a full set of UI components, containers, navigators, and layouts. Just to draw an analogy, Microsoft has released absolutely naked Silverlight 1.0 in 2007, but full featured Silverlight 2.0 became available a year after.
The good news is that Java developers have already started building their own open source components for JavaFX. The name of this project is jfxtras .

On the other hand, I see some features available for JavaFX developers that are missing in Flex.

For example, ActionScript doesn’t support multi-threading. This is not an issue when it comes to communication with remote sites – all remote calls are asynchronous and use callbacks for server-to-client data flows. But if you’d need to write or use an existing Java library that performs some CPU-intensive calculations on the client, I’m sure Java will beat ActionScript.  The syntax of both languages is pretty similar though (see http://flexblog.faratasystems.com/?p=115).
JavaFX supports eval() function that allows to compile and execute a piece of code on the fly. Flex doesn’t  support this useful feature.

Two-way binding already exists in JavaFX but in Flex will get it only in version 4.

I’ve yet to see some benchmarks comparing Flex and JavaFX network protocol.  The latter just offers XML and REST for data exchange between client and server.  Of course, you can program Java sockets or wrap up an RMI client into JavaFX – would it be faster than ActionScript Real-Time Messaging Protocol? We don’t know. Or take HTTP tunneling between   Java Applet and a server-side Java stream. Would it be faster than using AMF, an HTTP-based binary protocol? We don’t know yet.

JavaFX removes a lot of complications in developing mobile applications. It promises to remove the need of using Java SE for desktop and Java ME for mobile – JavaFX should be the only solution you need. JavaFX Mobile offers hardware acceleration.  Keep in mind, there are 2.6 billion of Java enabled mobile devices! JavaFX has serious advantage in this domain over Flash Lite.

JavaFX 1.1 is about to be released. It offers performance improvements, bug fixes, new features in the mobile space, but no major additions to the desktop platform.

I understand that this is not a good time to ask for some serious cash injections, but if executives of Sun Microsystems won’t find a way to double the size of the team working on the future version of JavaFX, entire Adobe Flex team can safely go on sabbatical for a year.  If the money is tight, the sooner JavaFX will go open source, the better.

Even though I wouldn’t start developing with JavaFX a project that needs to go in production this year, overall, JavaFX looks promising. Try it out and see for yourself.

tags:      

links: digg this    del.icio.us    technorati    




1. Viktoras left...
Friday, 20 February 2009 5:50 pm :: http://www.charnad.com

Dear Mr. Fain. First of all i want to ask for an excuse, i'm going to post a little offtopic comment. I'm 22 years old PHP programmer from Russia. I live in Russia for already 15 years (i was born in a small Baltic country), and already graduated the IT department of the university. I'm on the way to PhD now, but dont really sure i'm gonna get this. Though i'm a PHP programmer now, i've studied Java myself for a month and made a simple TCP/IP chat on Java a year ago with connection pool. Well, what's i'm talking about is my aim to move to USA or maybe some European country. So i want to ask you: what skills and qualifications do i need to apply for a job in USA for sure? I've wrote about Java chat earlier to show, that i can easily learn new things. I really love programing. Also, i think you have already noticed, that my English knowledge isn't bad. Could you please also tell me, can i apply for an american job from Russia? I really want to leave Russia. I love Russia very much, it's a great country that is gonna have great future, but still i dont think i'm fit for this kind of life. I dont want to pay my half-a-year salary for escaping russian army. (maybe i'll have to) I dont want to break the law.

So, all in all, could you please provide me some information on the topic? I've listened to your podcast and like it very much. I'm on chapter 22 at the moment.

P.S. I would really appreciate if you mail me the answer <char...@>, but still, i'll check this page too.

Thank you for your attention.


2. Muthu left...
Saturday, 21 February 2009 5:59 am

Hi Viktoras,

Greetings.AMERICA is a Great country and land of opportunities .It respects people who are having excellent skills in any field.

Get your work experience in an IT company at your country and improve your skills which should exceed American's expectations. Then Apply for H1B.

Best of luck,

Muthu (India)


3. Viktoras left...
Saturday, 21 February 2009 7:43 am :: http://www.charnad.com

Hi, Muthu. Thank you for your comment. At the time i have 1 year expirience as PHP programmer. Of course i realise there are a lot more things to learn, like software architecture, different frameworks and so on. Your note is very useful, because now i'm searching for H1B jobs in USA. Thanks for that. Best regards, Viktoras.


4. Yakov Fain left...
Saturday, 21 February 2009 2:17 pm

@victoras

I see that you can write in English, but you need to speak fluently too. Can you? Since you already started learning Java, keep moving in this direction, and I don't just mean Java language. Learn all the JEE stack too. By learning, I mean at least 6 hours a day just for learning. The next step is to learn another language that's a little less restrictive, i.e. ActionScript. Become one of the best in your current surrounding in Russia, and then start applying for a work permit in another country. But if you are not competitive, don't bother unless you have tons of money to pay your living expenses without having a good job. What type of visa is requires is the last thing to worry about. Become a professional first. Good luck!


5. Viktoras left...
Saturday, 21 February 2009 4:51 pm :: http://www.charnad.com

Thank you for comment. I can speak fluently. Maybe my pronunciation is still too russian, but practice makes things perfect) You are totally right, being a professional is a must. I like Java, but still i am a PHP programmer, i'm working very hard on this exploring symfony framework (they say it's Rails for PHP). In a year or two i'm going to apply for a job in US or some EU country. Maybe i'll fail, but i think you know russian saying 'A try is not a torture'. If i realise that PHP, RoR and Python are not very popular - i'll go Java way. Now i know what to do in that case :)

Thanks again.

P.S.> I really like your podcast. I dont agree with many things you say about Russia, but it's always good to know other points of view.