Pet Store with JavaFX 1.0.- Part I

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.

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 atthis 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 1.0 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 has been released on February 12, 2009. 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.

This article has been originally published on the Yakov Fain's blog and is printed with author's permission.

Related Stories

Yakov Fain is a Java Champion and a co-founder of the IT consultancy Farata Systems and the product company SuranceBay. He wrote a thousand blogs (http://yakovfain.com) and several books about software development. Yakov authored and co-authored such books as "Angular 2 Development with TypeScript", "Java 24-Hour Trainer", and "Enterprise Web Development". His Twitter tag is @yfain

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.

Artificial intelligence (AI) is the intelligence of machines and the branch of computer science which aims to create it. Major AI textbooks define the field as "the study and design of intelligent agents," where an intelligent agent is a system that perceives its environment and takes actions which maximize its chances of success. John McCarthy, who coined the term in 1956,defines it as "the science and engineering of making intelligent machines." The field was founded on the claim that a central property of human beings, intelligenceâ€”the sapience of Homo sapiensâ€”can be so precisely described that it can be simulated by a machine.

Cloud Expo

Cloud Computing & All That
It Touches In One Location Cloud Computing - Big Data - Internet of Things
SDDC - WebRTC - DevOps
Cloud computing is become a norm within enterprise IT.

The competition among public cloud providers is red hot, private cloud continues to grab increasing shares of IT budgets, and hybrid cloud strategies are beginning to conquer the enterprise IT world.

Big Data is driving dramatic leaps in resource requirements and capabilities, and now the Internet of Things promises an exponential leap in the size of the Internet and Worldwide Web.

The world of SDX now encompasses Software-Defined Data Centers (SDDCs) as the technology world prepares for the Zettabyte Age.

Add the key topics of WebRTC and DevOps into the mix, and you have three days of pure cloud computing that you simply cannot miss.

Delegates will leave Cloud Expo with dramatically increased understanding the entire scope of the entire cloud computing spectrum from storage to security.

Cloud Expo - the world's most established event - offers a vast selection of 130+ technical and strategic Industry Keynotes, General Sessions, Breakout Sessions, and signature Power Panels. The exhibition floor features 100+ exhibitors offering specific solutions and comprehensive strategies. The floor also features two Demo Theaters that give delegates the opportunity to get even closer to the technology they want to see and the people who offer it.

Attend Cloud Expo. Craft your own custom experience. Learn the latest from the world's best technologists. Find the vendors you want and put them to the test.