HTML5 Zone is brought to you in partnership with:

Kai Wähner (Twitter: @KaiWaehner, Blog: is an IT-Consultant in the Java EE, SOA, Cloud Computing and Big Data world. In his real life, he lives in Erlangen, Germany and works for TIBCO ( Besides solving huge integration problems for large companies, Kai writes articles for magazines and speaks at international IT conferences such as JavaOne. Feel free to contact him via Twitter, LinkedIn or Email. Kai is a DZone MVB and is not an employee of DZone and has posted 51 posts at DZone. You can read more from them at their website. View Full User Profile

When to use JavaFX 2 instead of HTML5 for a Rich Internet Application (RIA)?

  • submit to reddit

These days, we are starting a new project for realizing a Rich Internet Application (RIA). One of the first questions is: Which technologies and frameworks shall we use? The backend will be Java or another modern JVM language, as we are mainly experienced Java developer. In most use cases, we also prefer web frameworks, which allow to code mostly in Java, as many of us just have basic knowledge regarding HTML and JavaScript.

A decision has to be made for the upcoming project: Shall we use HTML5 or JavaFX 2 for realizing the web client? If you ask Google for “javafx or html5”, you do not find much information. In the majority of cases, you end up with a presentation hold at several IT conferences in 2011: “Moving to the Client: JavaFX and HTML5 Presentation”. Here is the Slideshare link (from JavaOne 2011): Because this presentation does not help much, we took a look at pros and cons, which are listed below in this blog post.

But let’s start from the beginning…

What is a Rich Internet Application (RIA)?

There is no real definition for RIA. Therefore, here is my definition for this blog post:

“A Rich Internet Application provides a modern looking web application with animations, effects and multimedia features. The web application is hardly recognizable as web application. There is no classic HTML user interface with forms, drop down boxes or tables. Typical features of web browsers such as bookmarking or forwards / backwards navigation are usually missing / not required. It is client-centric, i.e. most of the user interface is loaded at the beginning to offer very good responsiveness. Sometimes (i.e. if you use a web framework instead of just HTML5), a plugin must be installed (e.g. Java Runtime Environment or Adobe Flash Player). Pokerstars ( is a very good example for a RIA.”


Several alternatives are available in the JVM environment for realizing a RIA:

  • Plain HTML5: Good solution, but you do not code in Java or another JVM language.
  • Adobe Flash / Flex: Dead! Even Adobe moves to HTML5.
  • Microsoft Silverlight: Dead! Even Microsoft Windows 8 moves to HTML5. (Of course, Silverlight is no real JVM solution, but you can make it work together with JVM backend. For the sake of completeness, I added it to this list.)
  • JavaFX: Java-based solution (replacement for Swing in the future).
  • Other JVM web frameworks besides JavaFX (JSF, GWT*, Wicket, Tapestry, Grails, Lift, “You-Name-It”): Not built for realizing RIAs. Yes, you can realize a RIA with these frameworks. Though, development is ugly, and the RIA will be ugly, too. So why would you do this? (Please remember my above definition of a RIA before you begin complaining in the comments!)


* GWT also has nice (experimental) HTML5 support for some features already: => If Google continues adding support for HTML5 to GWT, this may be a good alternative in the next years, too - you develop only in Java, and you do NOT need a browser plugin because GWT generates plain HTML and JavaScript. However, there are also rumors that GWT is dying due to Google’s new language Dart. Google did not comment this yet, or release a roadmap for GWT.

So, the question is when to use JavaFX 2 instead of HTML5 for realizing a RIA (from the view of a Java developer)? If you do not know much about HTML5 or JavaFX, you should look at Wikipedia or google for other articles.

What is HTML5?


Important: HTML5 is HTML + CSS + JavaScript! It offers several next generation features for modern web development, such as Offline Storage or Application Cache.

What is JavaFX?


Reminder: We are talking about JavaFX 2.0. The main difference to earlier versions is that JavaFX now offers a Java API instead of a new programming language (JavaFX Script). Thus, it is easy to learn for a Java developer.

Why HTML 5 / JavaScript?


  • W3C standard
  • It’s the future – no question!
  • No plugin is required, can be used in every (supported) web browser
  • Already many widgets and features available


  • Development with HTML / JavaScript instead of Java => Main disadvantage for a Java developer!
  • Spec not final yet (according to the roadmap not before 2014!)
  • Not supported by all browsers (yet)
  • Cross-browser development is necessary (JavaScript frameworks such as jQuery or Dojo solve this problem, but increase efforts nevertheless)

Probably, there are many other pros and cons for HTML5. Though, the named ones should be sufficient for deciding when to use HTML5 or JavaFX.

Why JavaFX 2?


  • Offers a Java API => Leverage your Java skills and use existing JVM features and libraries
  • Offers DSLs for further JVM languages, e.g. Groovy (GroovyFX) and Scala (ScalaFX). Read this article to learn how to benefit by using modern JVM languages instead of Java: “JavaFX 2.0 and Scala, Like Milk and Cookies” =>
  • optional: “layouting” language FXML to split UI definition from behaviour => choose your favorite between programming (with Java) and layouting (with FXML)
  • Same development environment for backend and web client (including debugging, refactoring, etc.)
  • No cross-browser problems
  • CSS support (as in HTML)
  • HTML and / or JavaScript can be integrated in a JavaFX application
  • Swing and JavaFX can be used in same application, so existing Swing applications can be extended
  • JavaFX 2 provides a unified architecture for writing an application once and then deploying it to various contexts (standalone application, embedded in a web browser or run via Java Web Start). Additional contexts will be added in the future (e.g. running the same application on a mobile device).


  • Java Runtime Environment is required on client
  • Only parts of JavaFX are open source. The Oracle JavaFX runtime and SDK will continue to be released under the Java Binary Code License
  • JavaFX for Mac only available as Developer Preview (GA planned for the mid of 2012) => see JavaFX roadmap
  • JavaFX for Linux not available yet (Developer Preview planned for Q3 of 2012)
  • No information about future of JavaFX Mobile yet (at least I did not find anything, if someone has a link, please add a comment!)
  • Offers less widgets and other features than HTML5
  • Though JavaFX is the (future) replacement for Swing, development is different due to several new concepts. Of course, this is the consequence of adding RIA features such as animations => Thus, this is no real disadvantage, and its still easier for a Java developer to learn some new concepts than learning HTML and JavaScript


HTML5 and JavaFX 2 are both awesome for realizing RIAs including media, charts, animation, etc. In the end, both have a different target audience:

  • Public web applications should be realized with HTML5, because requiring a browser plugin is a no-go in most use cases. Therefore, even for Java developer there is no alternative to HTML5.
  • Within an enterprise, it may be acceptable to require a plugin. Probably, Java is already installed on most machines anyway. If all needed widgets and other features are available, JavaFX is the better choice for enterprise applications because a Java developer can realize RIAs much easier by developing in its well-known JVM environment.

Have fun realizing your RIA with HTML5 or JavaFX 2. By the way: We will probably choose JavaFX for our internal project because the required Java plugin is no show-stopper and most colleagues are Java developer.

If I missed any important pros or cons, or if you have any other feedback, please feel free to leave a comment…


Best regards,

Kai Wähner (Twitter: @KaiWaehner)

Published at DZone with permission of Kai Wähner, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


Marko Milicevic replied on Mon, 2012/04/23 - 9:58pm

Nice review Kai.

It's ironic that JavaFx has outlived Flex/Silverlight, but those strong/failed attempts may be an early indicator of where JavaFx is going.

On there other hand i think there is a lot of potential for JavaFx to be outstanding RIA platform and alternative to html5.  If/when it has a large collection of complex JavaFx UI components (like nextgen Jide components), then i would seriously consider using JavaFx for backend administrative apps that often have heavy interaction and data navigation/mgt.

Even more compelling combined with a framework like Griffon.

There is also fantastic html5 integration with the JavaFx webkit component/browser.

Then there are the public usecases like your example of, or online trading, or games like my son's favorite Minecraft (implemented in Java).  All these cases require max performance and/or a complex RIA UX and/or native device integration.  Yes, you can twist html5 to do the same, but at least for now it would be much less expensive and portable to use Java.

Eventually JavaFx on smartdevices could have potential.  In general the cases where native UX's outshine html5 (such as iOS) could be opportunity for JavaFX to provide a comparable UX, but portably.

I believe the plan is support cross-compile to HTML5.  That seems very difficult and ambitious, but if it worked well in a small/fast footprint, that could make JavaFx a player even in an HTML5 environment.

Similarly if they could portably cross-compile to native UI toolkits like iOS/Andriod. 

Roman Kasianenko replied on Tue, 2012/04/24 - 3:57am

JavaFX for Linux not available yet (Developer Preview planned for Q3 of 2012)

Actually, JavaFX 2.1 and 2.2 Developer Preview Releases are available for Linux (2.1 - is available for quite some time already, 2.2 - just became available recently) here:

Oliver Weiler replied on Tue, 2012/04/24 - 4:14am

Good solution, but you do not code in Java or another JVM language.

 Sounds more like a plus to me. I really like Java, but any type of UI development always felt like a pain in the ass. My advice is to invest two weeks to learn JS basics (JS is really that simple), and use Java where it fits best, i.e. backend development.

Mark Unknown replied on Tue, 2012/04/24 - 11:58am in response to: Oliver Weiler

Oliver, I have done a lot of UI dev in  both Java, C#, COBOL (IMS, CISC,Etc), VB (classic), and HTML/JavaScript.  While not perfect, Java (Swing, SWT) is much easier IMHO than JavaScript.  It takes much much more than a 2 weeks and just basic JS to do what can be done with Swing/SWT.  It takes a JavaScript lib (or more) and thus having to learn it. Currently those are in the same state as Java Web frameworks have been over the years (too many to choose from, each with their Pros and Cons). Also, JavaScript is just plan tough to navigate. Sure, things are getting better with IDE support, but I can't see they will be as good as something like Java. And there is the issue of visual design.  And debugging.

Mark Unknown replied on Tue, 2012/04/24 - 12:01pm in response to: Mark Unknown

Note: I am not, however, saying that the choice to use Java (JavaFX, etc) or JavaScript is easy. 

Alexander Kouznetsov replied on Thu, 2012/04/26 - 4:12pm

JavaFX 2.1 just released

Chris Clark replied on Wed, 2012/05/02 - 3:29pm in response to: Oliver Weiler

I agree - the IT world is making a lot of focus on HTML 5, CSS 3, and related new technologies. Browser makers are spending a lot of effort trying to incorporate the draft specs as they come along. There is an agreement that HTML 5 is the way to go, and with the shift towards powerful smartphones (e.g. Samsung's recent Android phones, and the latest tablets from Samsung and Apple), that the technology should be portable.

OK, I know that Javascript is not the favourite language of all developers, but for the time being it is getting a lot of focus.

My main request would be for someone to come up with a scripting language (something simple, like BASIC) that you would run an application and it would be seamlessly client-server (so would generate the browser stuff and the server instance automatically), and all you would need is one executable to run the script. Now wouldn't that be something ;-)

Fabrizio Giudici replied on Mon, 2012/05/07 - 5:30am

While I mostly agree with Mark, the basic points are different: fashion and deployability. Fashion is something we can't control and fashion today is definitely with HTML 5. Deployability unfortunately is a problem, because while the Java Plugin improved a lot in the past years, it's not yet optimized and hassle-free up to the point to keep a comparison with HTML 5. In other words, if your RIA must be accessible to everybody and "in a few seconds" (I mean, it must also capture random navigators), JavaFX is not an option. Also consider that Java is no more preinstalled by default on Mac OS X and, even though things aren't completely clear to me, this has got an impact on the effectiveness of Java Web Start.

Given that, I think that JavaFX is excellent where Swing were and is excellent, that is in industrial applications (where you don't have problems with deployment) or in ad-hoc situations (where users are committed to using a service and can tolerate some problem with the installation of the client).

For what concern mobile devices, to me is clear that the world is going to be dominated by Android and iOS for a long time, thus JavaFX can't play a role there, unless Oracle deploys a sort of "adapter layer" reimplemented on Android widgets. I don't know how feasible / practical it can be.

Mark Unknown replied on Tue, 2012/05/08 - 10:56pm

Fabrizio, I think we agree. My point was that Java is easier to code and maintain. The problem ... is what you described.  Running Java on the client is sometimes not the right choice and some times not possible.  

 What i am interested in is something like Eclipse RAP Mobile. With that you can write "HMTL5" apps in Java.  I have looked at all the major JavaScript HTML5 (ish) frameworks and tried most. While they are tons better the just plain JS,  they are still not simple to use and maintain.   I can't seem to decide on one. I seem to run into some  issue or something they don't support.

Mark Unknown replied on Wed, 2012/05/09 - 10:57am in response to: Mark Unknown

Another thing the I run into with JavaScript libraries, and something that is not always mentioned, is CSS. It is not "simple" either.  I would rather spend my time building apps that add value to the business rather than tweeking JS, CSS and HTML.

Murray Furtado replied on Tue, 2013/02/05 - 7:44am

 I don't think you can claim that Adobe Flex is dead! It is a mature technology with an abundance of frameworks such as Parsley, and RobotLegs to help leverage the development of sophisticated RIAs, and GraniteDS for powerful integration with back end Java services. OK it has been open sourced by Adobe, but that doesn't mean it is dead! Certainly in the financial services space I know Flex is being used to develop highly sophisticated applications at a number of big investment banks. There's no way I see such apps being developed in HTML5 yet and looking on Jobserve today there are currently no jobs here in the UK asking for JavaFX. The other benefit of using Flex is that there is a pool of experienced Flex developers to draw on when resourcing projects, which is always an important consideration for project managers.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.