20
White Paper JavaFX 2 blue infinity Version: 1.0 RC2 Date: 10.01.2012 Submitted to: Author: Jan Stenvall Sébastien Vandenbergh (supervisor) Contact:

blue-infinity White Paper on JavaFX by Jan Stenvall

Embed Size (px)

DESCRIPTION

blue-infinity consultant Jan Stenvall's white paper on JavaFX

Citation preview

Page 1: blue-infinity White Paper on JavaFX by Jan Stenvall

White Paper JavaFX 2

blue infinity

Version: 1.0 RC2

Date: 10.01.2012

Submitted to:

Author: Jan Stenvall

Sébastien Vandenbergh (supervisor)

Contact:

Page 2: blue-infinity White Paper on JavaFX by Jan Stenvall

White Paper JavaFX

© blue-infinity, proprietary and confidential page 2 of 20

Table of Contents

1. Introduction ............................................................................................................... 3

2. Business Analysis ....................................................................................................... 4

3. Architecture ............................................................................................................... 5

3.1 Background .............................................................................................................. 5

3.1.1 Architectural Overview ........................................................................................... 5

3.1.2 UI Design Architecture ........................................................................................... 5

3.1.3 Java APIs for JavaFX Features ................................................................................. 6

3.2 Hardware and Software Compatibility .......................................................................... 7

3.2.1 Operating Systems – Windows, OS X, GNU/Linux, iOS, Android .................................. 7

3.2.2 Dynamic Languages for JavaFX – Groovy, Scala, Clojure ............................................ 7

3.2.2.1 GroovyFX / ScalaFX ............................................................................................... 7

3.2.3 Support for other platforms .................................................................................... 8

3.3 Comparison Chart ..................................................................................................... 8

3.3.1 Third Party Frameworks and Libraries .................................................................... 10

3.3.1.1 JRebirth ............................................................................................................. 10

3.3.1.2 MigLayoutFX ....................................................................................................... 11

3.3.1.3 JFX Flow ............................................................................................................. 11

3.3.1.4 DataFX ............................................................................................................... 11

3.3.1.5 RedFX ................................................................................................................ 11

4. Development ............................................................................................................ 12

4.1 Development Environments ..................................................................................... 12

4.1.1 JavaFX IDE Support ............................................................................................. 12

4.1.1.1 NetBeans ........................................................................................................... 12

4.1.1.2 Eclipse ............................................................................................................... 12

4.2 Visual Design Development ...................................................................................... 12

4.2.2 UI Design Capabilities .......................................................................................... 13

4.2.2.1 Designer – Developer Workflow ............................................................................. 13

4.2.2.2 CSS Capabilities .................................................................................................. 14

4.3 Testing .................................................................................................................. 15

4.3.1 Unit Testing the UI Model ..................................................................................... 15

4.3.2 FXML Dependency Injection .................................................................................. 15

4.4 Best Practices ......................................................................................................... 15

4.4.3 Patterns and Architecture ..................................................................................... 15

4.5 Deployment ........................................................................................................... 16

4.6 Continuous Integration Support ................................................................................ 16

4.6.1 Build Tools.......................................................................................................... 16

4.6.1.1 Ant Support ........................................................................................................ 16

4.6.1.2 Maven Support .................................................................................................... 16

4.6.2 Sonar Rules ........................................................................................................ 17

4.6.3 Performance Tests ............................................................................................... 17

5. Road Map.................................................................................................................. 18

6. Conclusion ................................................................................................................ 19

7. References ............................................................................................................... 20

Page 3: blue-infinity White Paper on JavaFX by Jan Stenvall

White Paper JavaFX

© blue-infinity, proprietary and confidential page 3 of 20

1. Introduction

Background

This white paper will, in the changing world of information technology, provide guidance in choosing

what RIA platform to commit to.

When you are about to choose a platform, you will face enterprise-grade considerations like; How long

will these platforms be around? Which platform is best suited to meet the business and end-user

requirements? How is the performance under heavy data crunching, multitasking or other CPU

intensive operations and will the platform scale to handle an expanding future?

Integration with legacy systems, data structures, client machines and business processes will all inform

the choice of a UI technology. The CIO will also point out the fact that previous investments must be

preserved and utilized to the maximum.

Current Solutions

The two products Adobe Flex™ and Microsoft Silverlight™ are ruling the market of rich UI frameworks.

These are mature and have a broad market penetration. And many of the mentioned considerations

and challenges are handled by these platforms. The companies backing Flex™ and Silverlight™ are

reviewing their investments and are turning, slowly but firmly, their attention towards HTML5. Interest

for Flex and Silverlight is declining; the trend is visible on Google Insight for Search (Google 2011).

Figure 1. Google Insights for Search show relative interest levels of Flex (red), Silverlight (yellow) and JavaFX (blue).

However, HTML 5 is still in its infancy, at the moment and in the near future. Today is this technology

certainly not a complete replacement for Adobe Flash™ or Microsoft Silverlight™. These frameworks,

including HTML 5, may be valid options under many circumstances, but will not answer the call for

more sophisticated, complex and richer web experiences. And, in times of cost-cutting and

consolidation of services, there are more at stake.

JavaFX 2

This paves the way for JavaFX 2 (hereafter JavaFX) which has been updated to face the enterprise

challenges. With the strong backing from Oracle, JavaFX is a serious contender in the UI Framework

arena. Since JavaFX is built using Java, in concert with and for the Java community, it means that huge

investments and the amassed Java knowledge can be reused. This minimizes investments and brings a

faster return on investment.

According to the TIOBE Programming Community Index (TIOBE 2012), Java is still the number one

rated programming language. Java has a long track record and has been proven in the enterprise

environment. This along with a strong Java developer community will empower the adoption of JavaFX.

Page 4: blue-infinity White Paper on JavaFX by Jan Stenvall

White Paper JavaFX

© blue-infinity, proprietary and confidential page 4 of 20

2. Business Analysis

Rich Internet Applications (RIAs) are, according a report from Forrester (2010), frequently used for

delivering complex and valuable online experiences. Although the term RIA is likely to fade away, the

presence of several RIA technologies will still be the key to deliver online experiences that will satisfy

customer demands for complex and visually compelling User Interfaces.

As they look to create great online experiences of the future, customer experience professionals should

use RIAs for modernizing existing online functionality, building transformative new experiences, and

creating emotional connections with users.

Oracle is stepping up to the challenge and is increasing its investment in JavaFX, according to a recent

press release (Oracle 2010). And just like Adobe Flex™ is Oracle opening up JavaFX to the open source

community. This will enable the Java community to influence the direction of the future of JavaFX.

Oracle will, unlike the handover of Adobe Flex™ to the Apache Foundation, officially back the

community and will be at the helm of the OpenJFX organization. The JavaFX runtime will be a vital part

of the Java SE Development Kit 8.

Reuse Investments

JavaFX applications are completely developed in the Java programming language, one of the most

widely adopted technologies to develop and deploy software applications, which leverages standards-

based programming practices and design patterns. All your previous investments can be preserved by

reusing Java libraries in JavaFX applications.

Consultant Profile

Benefitting of the fact that the JavaFX stack is pure Java, companies and developers can leverage their

Java skills and it will be easier to find experienced consultants. They can use their favorite Java

development tools, such as the NetBeans and Eclipse IDEs. Hence, the learning curve is steep as Java

developers will easily be acclimatized to Java and the JavaFX 2.x API.

Comparing job offer trends, reveals that the UI frameworks Flash™, Flex™ and Silverlight™ trails the

java job trend. The demand for Java developers are more than 15-fold greater. The continued high

demand for Java developers is a safeguard for a wide adoption of Java and JavaFX.

Figure 2. Indeed Job Trends - Flex vs. Silverlight (Q1 2012) Figure 3. Indeed Job Trends – Java (Q1 2012)

Page 5: blue-infinity White Paper on JavaFX by Jan Stenvall

White Paper JavaFX

© blue-infinity, proprietary and confidential page 5 of 20

3. Architecture

3.1 Background

JavaFX 2 is a revolution of the JavaFX 1.x version. The JavaFX Script API has been remodeled and

rebuilt using Java. The JavaFX Script API has been converted to pure Java. The main architectural

design goals were: Use the richness of Java like modern concurrency, properties and bindings, CSS

support separates style and logic, etc.

3.1.1 Architectural Overview

Figure 4. Architectural block diagram showing the complete module stack of JavaFX 2.0.

This diagram shows the JavaFX component stack.

The top layer represents the JavaFX public APIs and the JavaFX Scene Graph.

The next layer is the Quantum Toolkit which ties Prism and Glass Windowing Toolkit together

and makes them available to the JavaFX layer.

The third layer:

- Prism, processes render jobs

- Glass Windowing Toolkit, provide native operating services (windows, timers, surfaces)

- Media Engine, supports both visual and audio media

- Web Engine, provides a web viewer and full browsing functionality (WebKit-based)

The fourth layer consists of the Java 2D, OpenGL, and D3D, graphics rendering services

The Quantum Toolkit, Prism, Java 2D, OpenGL, and D3D, make up the JavaFX Graphics System.

The lowest layer is the Java Virtual Machine which sits underneath the JavaFX Graphics System, Glass

Windowing Toolkit, Media Engine, and the Web Engine.

3.1.2 UI Design Architecture

The JavaFX scene graph, shown as part of the top layer in figure 4, is the starting point for

constructing a JavaFX application. A single element in a scene graph is called a node. Each node has an

ID, style class, and bounding volume. Each node in a scene graph has a single parent and zero or more

children. It can also have the following:

Effects, such as blurs and shadows

Page 6: blue-infinity White Paper on JavaFX by Jan Stenvall

White Paper JavaFX

© blue-infinity, proprietary and confidential page 6 of 20

Opacity

Transforms

Event handlers (such as mouse, key and input method)

An application-specific state

The javafx.scene API allows the creation and specification of several types of content, such as:

Nodes: Shapes (2-D and 3-D), images, media, embedded web browser, text, UI controls,

charts, groups, and containers

State: Transforms (positioning and orientation of nodes), visual effects, and other visual state

of the content

Animation: Varying properties of the scene graph objects over time

Effects: Simple objects that change the appearance of scene graph nodes, such as blurs,

shadows, and color adjustment

Tour de JavaFX - Ensemble

Oracle has provided an equivalent of Adobe Flex showcase “Tour de Flex”. It is named Ensemble and is

found at the following address (To run it, you must have the JavaFX Runtime installed):

http://download.oracle.com/otndocs/products/javafx/2.0.2/samples/Ensemble/index.html

Figure 5. JavaFX showcase application Ensemble.

3.1.3 Java APIs for JavaFX Features

These new Java APIs for JavaFX features allow the use of powerful Java features, such as generics,

annotations, and multithreading.

Page 7: blue-infinity White Paper on JavaFX by Jan Stenvall

White Paper JavaFX

© blue-infinity, proprietary and confidential page 7 of 20

One of the most powerful features of the API is the use of bindings, similar to that in JavaFX 1.x Script

language. This includes support for high performance lazy binding, binding expressions, bound

sequence expressions, and partial bind re-evaluation.

It also allows extending of the Java collections library to include observable lists and maps, which allow

applications to wire user interfaces to data models, observe changes in those data models, and update

the corresponding UI control accordingly.

3.2 Hardware and Software Compatibility

3.2.1 Operating Systems – Windows, OS X, GNU/Linux, iOS, Android

JavaFX has a multilayer architecture that has been designed with portability in mind. The Internal API

is a course-grained porting layer. The JavaFX APIs is isolated from implementation details. This allows

porting to completely different systems (Operation Systems/Architectures).

JavaFX does run on devices like iOS and Android using exactly the same application code and exactly

the same JavaFX layer are used for the iOS version. But it is using an iOS specific implementation of

the abstraction layer Glass.

The Windowing API, Glass, runs (or will run) on the following systems Windows (Win 32), Mac (Cocoa),

GNU/Linux (GTK) and Headless.

3.2.2 Dynamic Languages for JavaFX – Groovy, Scala, Clojure

The JavaFX API enables dynamic languages to use JavaFX. By extension these languages support full

interoperability with Java and can run anywhere the Java Virtual Machine (JVM) and JavaFX are

supported. Hence, you can use scripting languages that produce bytecode compatible with the JVM,

such as Groovy, Scala or Clojure, if you prefer to use a declarative language.

Scala is a general purpose programming language designed to express common programming patterns

in a concise, elegant, and type-safe way.

Groovy is an optionally typed, dynamic language for the Java platform with many features that are

inspired by languages like Python, Ruby, and Smalltalk, making them available to Java developers

using a Java-like syntax.

Clojure (http://clojure.org) is a dynamic programming language that targets the Java Virtual Machine

(and the CLR, and JavaScript). It is designed to be a general-purpose language, combining the

approachability and interactive development of a scripting language with an efficient and robust

infrastructure for multithreaded programming.

3.2.2.1 GroovyFX / ScalaFX

GroovyFX (http://groovy.codehaus.org/GroovyFX) is an API that simplifies working with JavaFX using

Groovy. It enables a much simpler and more natural way to use JavaFX for those well-versed in

Groovy. GroovyFX is focused on leveraging the Builder pattern for JavaFX applications, and it leverages

some of the capabilities that Groovy provides and makes the Groovy based JavaFX code easier to

write.

Page 8: blue-infinity White Paper on JavaFX by Jan Stenvall

White Paper JavaFX

© blue-infinity, proprietary and confidential page 8 of 20

ScalaFX (http://www.scalafx.org) is an abstraction layer on top of JavaFX written with Scala that sits

on top of JavaFX. This means that every ScalaFX application is also a valid Scala application.

3.2.3 Support for other platforms

Oracle is investing time and resources to get Java to run on other hardware platforms than Intel™.

They have released the Java SE JDK for Embedded on ARM™ and x86 platforms. This is driven by the

explosion of smartphone and other modern devices.

The release of JavaFX version 2.0.2 introduced interoperability with the Standard Widget Toolkit

(SWT). This extends the possibilities to use JavaFX in either Swing or SWT applications.

3.3 Comparison Chart

Since Microsoft will cease supporting plugins in Internet Explorer 10 (Sinofsky, Blog post Q3 2011),

this incurs that Silverlight™ is not a viable option in the future. Hence, presented below is a

comparison between the two open source frameworks Adobe Flex™ and JavaFX.

Category Adobe Flex™ JavaFX

Maturity Very mature, v1.0 released 2004 Immature, v2.0 Released Q4 2011

Language MXML for its declarative aspects, ActionScript for the programmatic aspects

FXML for its declarative aspects, Java for the programmatic aspects

Controls &

Components

50+

+ many other components, both open-

source and commercial

50+

+ increasing amount of open-

source components

Deep Linking Yes No

Charts Yes Yes

Browser Back/Forward Yes No

Data Binding Yes Yes

2D, 3D Effects Yes, with Flash 10+ Yes

Animations, Transformations

& Effects

Yes Yes

CSS Styling Yes Yes, CSS 2.1

GPU Hardware Acceleration

Yes, with Flash 10+ Yes, since 2.0

HD Video

Yes, with H.264. Also support for true HD video (1080p)

Yes, but not H.264. FLV containing VP6 video and MP3 audio

Localization Yes Yes

JavaScript Interaction

Yes, both ways Yes, both ways

Multi-threading No Yes, utilizing Java’s threading capabilities

Page 9: blue-infinity White Paper on JavaFX by Jan Stenvall

White Paper JavaFX

© blue-infinity, proprietary and confidential page 9 of 20

Tooling – Development FlexBuilder IDE is mature Focus on developers, i.e. NetBeans, Eclipse, IntelliJ, etc.

Tooling – UI Designer Since 2006, but not very good None, scheduled in mid-2012

Runtime Availability Ubiquitous, but unavailable on iOS 96% of all browsers

JavaFX bundled with JRE and available on iOS 75% of all browsers

Developer Community Very active developer community Active developer community

Governance Spoon project started by Adobe will govern the development of the Flex Framework.

OpenJFX started by Oracle will in due time “own” the JavaFX code base.

License Free Adobe Flex SDK: Adobe Flex SDK license

Open Source Flex SDK: open-source (Mozilla Public License 1.1) Adobe Flash Player: Proprietary freeware EULA

Adobe Flash Builder: Proprietary EULA Adobe Catalyst: Proprietary EULA

OpenJFX releases: GPL v2 with Classpath Exception

license (1991)

JavaFX: Java Binary Code License (Q4 2011)

Table 1. Comparison between technical and non-technical characteristics of Adobe Flex™ and JavaFX.

Page 10: blue-infinity White Paper on JavaFX by Jan Stenvall

White Paper JavaFX

© blue-infinity, proprietary and confidential page 10 of 20

3.3.1 Third Party Frameworks and Libraries

The worldwide Java community has gathered and built a vast knowledge and structure capital during

the lifetime of Java. All current and future Java frameworks and libraries are available to the JavaFX

developer. There are also third party frameworks and libraries available to extend and supplement the

basic JavaFX API.

The JavaFX community is growing and every week there is new components available to use. The

following sub-sections cover some of the community-provided (third party) JavaFX frameworks and

libraries available at the time of writing. GroovyFX and ScalaFX have already been mentioned above.

3.3.1.1 JRebirth

JRebirth (http://www.jrebirth.org) is a JavaFX framework that simplifies writing powerful RIA's

applications. It is a WCS-MVC pattern with 6 main layers:

Application: The Application is the starting class to extend to build a JavaFX application

that use JRebirth framework. GlobalFacade: The GlobalFacade is used to simplify access to the other layers. CommandFacade and Commands: The

Command layer is used to manage complex group of actions (MultiCommand) (synchronously or asynchronously), or atomic reusable action (Command).

All interactions between layers must be managed by Commands.

ServiceFacade and Services: The Service layer is used to retrieve Data from outside the application or to communicate with others applications. UiFacade and Models: The Model layer is

used to manage the loading of the data displayed into a view, for example by calling a service. Controllers: A Controller manages the View's Interactions logic. It's used to intercept all

JavaFX components' events.

Views: The view layer is used to create user interface by using JavaFX core components.

Figure 6. JRebirth Framework diagram.

Page 11: blue-infinity White Paper on JavaFX by Jan Stenvall

White Paper JavaFX

© blue-infinity, proprietary and confidential page 11 of 20

3.3.1.2 MigLayoutFX

MigLayoutFX2 (formerly called MigPane, http://www.miglayout.com) is a wrapper for MigLayout, one of

the most powerful layout managers for Swing. This wrapper allows you to use the power of MigLayout

to layout nodes in JavaFX.

Figure 7. Picture showing a MigLayout simple layout example code.

3.3.1.3 JFX Flow

JFX Flow (http://www.zenjava.com/jfx-flow) is a free, open source framework for developing rich,

interactive and user friendly web-style GUIs for desktops using JavaFX (2.0+). JFX Flow combines the

powerful feature set of Java FX (styling, animations, FXML, etc.) with a simple ‘web flow’ style

framework, that is easy to use and that fosters clean architectural patterns, especially when developing

JEE applications.

Supports simple, user friendly “web-style” user interface design

Provides built-in navigation support for browser-like applications (back, forward, refresh, etc)

Facilitates a modularized application architecture of reusable components with clean separation

of concerns (i.e. separate view code from control code)

Provides integration with JEE technologies, such as Spring, Guice, databases and web services.

Provides a toolkit for common user interface tasks such as blocking while loading, error

handling, animated page transitions and more.

3.3.1.4 DataFX

In summary, the DataFX (http://www.javafxdata.org) project aims to make the process of using

JavaFX ListView, TableView, and TreeView controls easier, more functional, and more powerful. It

provides various data source adapters to ensure convenience around populating JavaFX controls.

3.3.1.5 RedFX

RedFX (http://www.redfx.org) provides functionality that allows JavaFX applications to share data with

each other and with server applications without the need of writing lots of specific boiler plate code.

The synchronization and messaging infrastructure is provided by RedFX. The code was originally

written for JavaFX 1.3.1 but has been ported to JavaFX 2.

1. use RemoteObjects in order to synchronize data between JavaFX clients or between clients

and a server application.

2. use the MessageService to publish and consume Objects and events. Both clients as well

as server software can create a Channel and publish/consume data.

3. use the WebServiceClient in order to make REST calls to existing back-end systems.

Page 12: blue-infinity White Paper on JavaFX by Jan Stenvall

White Paper JavaFX

© blue-infinity, proprietary and confidential page 12 of 20

4. Development

4.1 Development Environments

To start developing JavaFX, you need to install the JavaFX SDK, either standalone or bundled with the

latest Java SE Development Kit version 7 update 2 (Windows). Future releases of JavaFX will be

synchronized with the releases of Java SE Development kit.

4.1.1 JavaFX IDE Support

JavaFX is based on the Java language. Developers can thereby use their favorite Java development

tools, such as the NetBeans and Eclipse, for development of JavaFX applications. All the standard IDE

features, including syntax highlighting, auto-completion, interactive step-through debugging, and

profiling are available for JavaFX developers. This is a major benefit and lowers the entry level for

developers new to JavaFX.

4.1.1.1 NetBeans

NetBeans 7.1 supports full compile, debug and profile development cycle for JavaFX applications.

However, NetBeans does not provide code completion for the FXML file format. But evidently, Code

Completion for the Java/JavaFX code of course available out-of-the-box.

4.1.1.2 Eclipse

Eclipse provides the same support for JavaFX and more by using a third party plugin called e(fx)clipse

(http://efxclipse.org). e(fx)clipse extends the Eclipse IDE and provides in fact its own variant of code

completion for FXML, hereby circumventing the lack of DTD/ XSD Schema for FXML. The plugin

integrates with JDT (e.g. JavaDoc for referenced elements, auto completion support, etc.).

4.2 Visual Design Development

The current Oracle JavaFX suite of tools does not offer an application for WYSIWYG development of the

user interface. The implementation of a user interface designer in NetBeans named Composer is

currently being redeveloped to be able to handle JavaFX in the future. Oracle are developing an

application named JavaFX Scene Builder, and has declared the General Availability release in mid-

2012. Currently Oracle previews a non-public beta version of the application. It is available by

invitation only.

The separation of application logic and presentation is based on the FXML. FXML is an XML-based

declarative markup language for defining the user interface in a JavaFX application.

Page 13: blue-infinity White Paper on JavaFX by Jan Stenvall

White Paper JavaFX

© blue-infinity, proprietary and confidential page 13 of 20

The following section outlines some of the JavaFX Scene Builder Features and an early screenshot of

the application:

Simple drag and drop positioning of GUI elements

Graphical FXML editor

Strong mapping to JavaFX APIs

Set and preview JavaFX properties and effects

CSS setting and previewing

Fully written with JavaFX version 2.0 APIs!

Figure 8. Screenshot of the Beta version of the Scene Builder application built with JavaFX.

4.2.2 UI Design Capabilities

4.2.2.1 Designer – Developer Workflow

JavaFX allows designers and developers to work on rich Internet applications (RIAs) concurrently. Here

is an example of an iterative designer-developer workflow.

1. Designers and developers meet to draw a graphic prototype and agree on the graphic

objects and their names. This step is very important, because it ensures that the designer

can drop the graphic into the application when it is ready without causing rework.

2. The designers create the graphic content using their design tools, while the developers

create the business logic of the application, using the rough sketch as a placeholder and

the graphic object names for their object IDs.

3. The content design and business logic go through as many iterations as necessary.

4. When both the content and business logic of the JavaFX application is final, it is deployed.

With JavaFX it is possible to map Adobe Photoshop™ elements to JavaFX code. And by using Adobe

Illustrator™ you can create vector based graphics (SVG) and copy paths directly into the JavaFX code.

Page 14: blue-infinity White Paper on JavaFX by Jan Stenvall

White Paper JavaFX

© blue-infinity, proprietary and confidential page 14 of 20

4.2.2.2 CSS Capabilities

JavaFX enables the use of Cascading Style Sheets (CSS) which provides the ability to apply customized

styling to the user interface of a JavaFX application without changing any of that application's source

code. CSS can be applied to any node in the JavaFX scene graph and are applied to the nodes

asynchronously. CSS styles can also be easily assigned to the scene at runtime, allowing an

application's appearance to dynamically change.

JavaFX CSS is based on the W3C CSS version 2.1 specifications, with some additional functions from

current work on CSS version 3.

In combination with FXML, using CSS further separates the application logic from the visual style.

Figure 9. Screenshot of an example application showing the CSS capabilities of JavaFX

Page 15: blue-infinity White Paper on JavaFX by Jan Stenvall

White Paper JavaFX

© blue-infinity, proprietary and confidential page 15 of 20

4.3 Testing

4.3.1 Unit Testing the UI Model

There are no official UI test tools available. Oracle is leaning on the Java/JavaFX community to supply

these tools.

It is possible, by using JavaScript, to reference Java code in the JavaFX object. In other words, it is

possible to use JavaScript to retrieve references to Java objects. You can access static fields or invoke

static methods for classes loaded by a given JavaFX application. This enables Selenium UI tests. All

tests of the JavaFX UI framework must be done by executing JavaScript calls to the JavaFX object.

There is a third party UI test tool called SmartBear loadUI (SmartBear acquired eviware software in

2011). But it is only possible to test JavaFX 1.3.x.

4.3.2 FXML Dependency Injection

At the moment there is no way to Dependency Inject components specified in the FXML file, which

impair the test fixture setup. The FXML specifies the concrete implementation of the controller classes

and not their interfaces or abstract classes. Hence with JavaFX version 2.0.2, it is not possible to use

the Dependency Injection pattern in the development and testing of the application.

The JavaFX team is currently working on a solution according to the following bug, http://javafx-

jira.kenai.com/browse/RT-14880.

4.4 Best Practices

4.4.3 Patterns and Architecture

The usual software design patterns also applies to JavaFX. But there are also other aspects affecting a

user interface application. Martin Fowler has touched upon this subject in the following post:

http://martinfowler.com/eaaDev/uiArchs.html

In the official Oracle JavaFX forum, JavaFX team members point to the JFX Flow project as a reference

for best practices when developing a JavaFX application.

Page 16: blue-infinity White Paper on JavaFX by Jan Stenvall

White Paper JavaFX

© blue-infinity, proprietary and confidential page 16 of 20

4.5 Deployment

Since JavaFX adheres to the Java standard, applications can be deployed on a desktop or in a browser

in four different deployment modes:

Standalone: The JavaFX application is installed on a local drive and is run by double-

clicking the JAR file (or multiple jar files for large applications). This mode is ideal when

users do not need or do not have online access.

Browser: In this mode, the JavaFX application is embedded in a web page and is started

automatically when the web page is accessed. It can interact with the web page through

JavaScript.

WebStart: This mode downloads the application from a central location on the web and

then runs it on the desktop. Once it is downloaded, users can start the application by

double-clicking the JNLP file.

Launched from a desktop shortcut: Users can create a desktop shortcut for a remote

Web Start or embedded application to simplify its subsequent launch.

4.6 Continuous Integration Support

4.6.1 Build Tools

You may develop JavaFX with your favorite Java IDE and even on the command line. To build, package

and release your application, there is support for Ant (out-of-the-box) and Maven (third party).

4.6.1.1 Ant Support

The JavaFX SDK includes Ant tasks that enable the assembling and packaging the JavaFX binaries

according to the deployment strategy chosen. As previously, it is possible to sign the jar files for

increased security.

Creating one or more JAR files

Creating an HTML page and deployment descriptor for Web Start applications or applications

embedded in a web page

Digitally signing an application, when necessary

Converting CSS files to binary format

4.6.1.2 Maven Support

As of now, there is no official support for building JavaFX projects with Maven. There are workarounds

but the main obstacle is that the JavaFX runtime relies on a DLL file (for Win32), i.e. you must first

Page 17: blue-infinity White Paper on JavaFX by Jan Stenvall

White Paper JavaFX

© blue-infinity, proprietary and confidential page 17 of 20

install runtime binaries. You must add the runtime jar files to your local maven repository or your

repository manager of choice, e.g. Archiva, Nexus etc.

At the moment JavaFX core contains proprietary components that prohibit the distribution of the

runtime using maven repositories.

As mentioned above, there are no Maven plugins for JavaFX. However, using the maven-ant-plugin it is

possible for Maven to execute the Ant tasks.

4.6.2 Sonar Rules

Continuous Integration provides the means to increase code quality in general. Using Sonar adds

measuring of code metrics and validation of best practices. There are best practices for developing

JavaFX applications. However, these have not yet been “officially” translated to Sonar rules. The

community provides information and even makes available Sonar rule sets. Since JavaFX is Java, the

usual Java rules apply to the JavaFX specific code.

The following rules sets are used to validate the JRebirth Framework:

http://blog.webeo.fr/public/Sonar/rules-active.csv

http://blog.webeo.fr/public/Sonar/rules-inactive.csv

4.6.3 Performance Tests

A repeat of the already stated fact, JavaFX is Java. This is just another java application which means

that you may reuse and/or create new unit performance tests that are executed in the build phase.

This leverages your previous investments even further.

Page 18: blue-infinity White Paper on JavaFX by Jan Stenvall

White Paper JavaFX

© blue-infinity, proprietary and confidential page 18 of 20

5. Road Map

At JavaOne 2010, Oracle laid out a long-term roadmap for JavaFX to make it a premier rich client

platform. JavaFX version 2.0 is a significant milestone towards fulfilling this vision.

Figure 10. Diagram showing the roadmap of the JavaFX product line.

Open Source

Oracle released JavaFX version 2.0 at JavaOne 2011 and made an announcement of its open source

status. Oracle want JavaFX to be open sourced under a “GNU General Public License, version 2, with

the Classpath Exception” (1991), similar to other projects in the OpenJDK Community.

Tighter Integration with Java SE (OpenJDK)

JavaFX will be tightly integrated as part of JDK 8 platform that will see an integration of JavaFX in the

OpenJDK, thus ensuring widespread adoption, synchronized updates and security fixes. JavaFX SDK

and runtime is bundled with the release of Java SE 7 update 2 (for Windows).

JavaFX 3 in JDK 8

Furthermore, delivering on the cross platform promise, JavaFX will become available simultaneously

across Windows, Mac, and Linux implementations of Java SE 8, allowing cross platform deployment of

applications as soon as the product becomes generally available.

Oracle intends to file a JSR in the Java SE 9 time frame to make it a Java standard.

Advanced tooling

JavaFX Scene Builder is a WYSIWYG GUI design tool for the JavaFX platform. It enables designing user

interface screens by simply dragging and positioning GUI components from a palette onto a scene. The

tool generates files in FXML format2 that can be used within a project in any IDE such as NetBeans or

Eclipse. The JavaFX Scene Builder can be used to create GUIs for desktop applications and applets that

run in a browser.

Planned Features

According to the official roadmap will JavaFX provide support for modern device interaction (e.g.

chipsets ARM, MIPS and multi-touch screens).

Modularization is one of the key features of Java SE 8. JavaFX will adhere to this and will be

modularized to completely leverage the benefits provided by the modularized Java SE 8.

Page 19: blue-infinity White Paper on JavaFX by Jan Stenvall

White Paper JavaFX

© blue-infinity, proprietary and confidential page 19 of 20

6. Conclusion

While Flex and Silverlight are compared in the RIA white paper published in June 2009 by the market

research company Gartner, JavaFX 1.x is not even mentioned (Knipp & Valdes, 2009). Fast-forward to

2011, and Oracle introduces JavaFX version 2.0. This reboot of JavaFX 1.x have yet to be fully digested

by the Java community and by companies.

Even though JavaFX is missing UI Design tool, this will not hinder the continued adoption of JavaFX

since most applications are more or less developed without using such a tool. JavaFX still lags in

certain areas compared to other plugin-based frameworks, but Oracle is outlining an aggressive

roadmap for the near future.

The unique selling point is the fact that JavaFX leans on the enterprise proven Java language.

JavaFX has more stable components and a greater selection than previously, it is a good alternative for

Java developers when developing front-ends to stand-alone applications. JavaFX will find a use case

within applications aimed to a limited group of users, in intranets or environments that are identical

and configured centrally, in order to work more seamlessly.

The relatively sparse usage of JavaFX, as compared to the other frameworks, is confirmed by looking

at the current market. There are barely any results on job search websites, and not much information

to be found about it neither online nor on forums.

But JavaFX eco-system is evolving very fast; more and more articles are published and are find their

way onto the internet.

JavaFX will soon be the only company backed plugin-based UI framework that is aiming for the

enterprise market.

Page 20: blue-infinity White Paper on JavaFX by Jan Stenvall

White Paper JavaFX

© blue-infinity, proprietary and confidential page 20 of 20

7. References

Google Insights for Search, Beta (Q1 2012)

http://www.google.com/insights/search/#q=javafx%20%2B%20java%20fx%20%2B%20%22java%20

fx%22%2Cflex%20%2B%20adobe%20flex%20%2B%20%22adobe%20flex%22%2Csilverlight%20%2

B%20microsoft%20silverlight%20%2B%20%22microsoft%20silverlight%22&cmpt=q

TIOBE Programming Community Index (Q1 2012)

http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html

Forrester report on RIA (Q4 2010)

http://www.forrester.com/rb/Research/rich_internet_applications_will_power_online_experiences/q/id/47919/t/2

Oracle Press Release - Oracle Increases Investment in JavaFX and Outlines Product Roadmap (Q3 2010)

http://www.oracle.com/us/corporate/press/173728

Indeed Adobe Flash™, Flex™ and Microsoft Silverlight™ Job Trend (Q1 2012)

http://www.indeed.com/trendgraph/jobgraph.png?q=%28%22adobe+flex%22+or+%22adobe+flash%22+or+actio

nscript%29%2C+silverlight

Indeed Java Job Trend (Q1 2012)

http://www.indeed.com/trendgraph/jobgraph.png?q=java

Steven Sinofsky, Blog post (Q3 2011)

http://blogs.msdn.com/b/b8/archive/2011/09/14/metro-style-browsing-and-plug-in-free-html5.aspx

GNU General Public License, version 2, with the Classpath Exception (Q2 1991)

http://openjdk.java.net/legal/gplv2+ce.html

Oracle Binary Code License Agreement for the Java SE Platform Products and JavaFX (Q4 2011)

http://www.oracle.com/technetwork/java/javase/terms/license/index.html

Knipp, Eric. Valdes, Ray. (2009). Navigating the Ajax vs. 'Heavy RIA' Dilemma. Gartner, Inc.

Moritz, Florian. (2008). Rich Internet Applications (RIA): A Convergence of User Interface Paradigms of Web and

Desktop

Exemplified by JavaFX. Diploma Thesis, University of Applied Science Kaiserslautern, Germany. Available:

http://www.flomedia.de/diploma/documents/DiplomaThesisFlorianMoritz.pdf

Rich Internet Applications (RIAs) – A Comparison Between Adobe Flex, JavaFX and Microsoft Silverlight (2009)

http://publications.lib.chalmers.se/records/fulltext/116839.pdf

GENERAL REFERENCES

Oracle JavaFX homepage: http://www.oracle.com/javafx

OpenJDK OpenJFX homepage: http://openjdk.java.net/projects/openjfx

Selection of Third Party Frameworks and Libraries

http://www.javafxdata.org http://www.jrebirth.org http://www.redfx.org

http://www.miglayout.com http://java.net/projects/miglayoutfx2 http://www.zenjava.com/jfx-flow