What’s new in Java 8 (Part II – What might come)

Disclaimer: I do not work for Oracle or represent Oracle in any way. This list of features is not official. This is just part of my research as an “outsider”.

This is part II of a three part series of posts. In the first part, I talked about what Oracle has officially let developers know what should come out in JavaFX 8 (JavaFX is the new UI library for Java), I have been updating that article with new information that I come across.

In this second part I’ll talk about what might be coming in this Java8 release or a release some time after.

What might come

Support for ios and android

Official support for ios and android might be on its way. There is already a non Oracle effort to bring ios and android support to JavaFX called RoboVM, however it is still in its alpha stage and has a long way to become a fully formed commercially viable solution.

Oracle has not yet made any statement that it will officially support this platforms, yet there are some indications that this is already happening. Just look at these sessions on this years JavaOne from Oracle staff members, that @tobibertoni (twitter user name) has mentioned:

Build and Debug Your JavaFX Application for the iPad [BOF5517]

* David Pulkrábek – Senior Software Developer, Oracle
* Oldřich Matička, Oracle

JavaFX for iOS has begun to move to open source. In this session, you will see how to turn your JavaFX NetBeans project into a real iPad application. You will also be shown how to debug a JavaFX application on your device by using the Java Platform Debugger Architecture (JPDA) and step-by-step instructions for adding custom Java Native Interface (JNI) code to an iOS application.

https://oracleus.activeevents.com/2013/connect/sessionDetail.ww?SESSION_ID=5517

JavaFX on Android: First Insight [BOF7791]

* Tomáš Brandalík, Oracle

The gap between desktop and embedded has been filled with JavaFX on Android and iOS. JavaFX running on Android enables you to connect with tens of million of devices. This session gives you everything you need in order to successfully develop JavaFX applications on Android. First, it walks you through the complete development process, from project setup to debugging. Second, it explains the main building blocks: packaging, installation, the application lifecycle, fonts, interaction with device and operation system services, media, and WebView. Finally, it wraps up with the build structure and how developers can control and customize their own builds.

https://oracleus.activeevents.com/2013/connect/sessionDetail.ww?SESSION_ID=7791

High-Performance Java Applications Without Dynamic Code: Ahead-of-Time Code Generators for iOS [BOF4099]

* Robert Vandette – Consulting Engineer, Oracle

The Apple iOS and Android operating systems used in popular mobile devices are high-volume platforms that until now have lacked compliant Java support. This session describes Oracle’s plans to bring the latest Java language and API features from Java SE 8 to the Oracle ADF Mobile feature of Oracle Application Development System (Oracle ADF) for iOS and Android application development. It also discusses the features contained in the JDK 8 for Oracle ADF Mobile implementation and how to develop Java applications that target iOS and Android.

https://oracleus.activeevents.com/2013/connect/sessionDetail.ww?SESSION_ID=3783

JavaFX on the Web

Oracle is working on making it possible to run JavaFX on the web without any need for plug-ins (which are now being prohibited from use on several platforms). You can already check Bck2Brwsr, now on its 0.7.2 version.

Another idea is WebFX a specialized browser which can consume FXML directly.

Spice Up Your Browser with JavaFX [BOF7830]

* David Pulkrábek – Senior Software Developer, Oracle
* Oldřich Matička, Oracle

JavaFX is a powerful multiplatform graphics technology, but is it possible to run your JavaFX application in a browser without a plug-in? Directly from class files? Of course, it is! This session demonstrates a plug-in-free solution that brings JavaFX to your browser.

https://oracleus.activeevents.com/2013/connect/sessionDetail.ww?SESSION_ID=7830

The Chuck Norris Experiment: Running Java in Any Browser Without a Plug-in [CON4044]

* Jaroslav Tulach – NetBeans Platform Architect, Oracle
* Anton Epple – Trainer and Consultant, Eppleton
“Chuck Norris can run Java in any browser—without a plugin”. Find out what you need in order to reproduce Chuck’s roundhouse kick. In this session, you’ll learn everything you need in order to get started with “bck2brwsr”, a new open source project. Besides in GWT, the bytecode isn’t compiled to JavaScript but runs in a JavaScript-based JVM. The session shows you how simple it is to extend the capabilities of this project by creating your own APIs, which enables you to create maintainable applications by using, instead of JavaScript, a statically typed language with excellent tool support that runs in any modern browser. You’ll see a demo of building a Space Invaders–type game that runs on the iPad as well as Android devices. This is not a preview; you can use it today.

https://oracleus.activeevents.com/2013/connect/sessionDetail.ww?SESSION_ID=4044

WebFX: Running JavaFX Like HTML5 Apps [BOF3132]

* Bruno Borges – Principal Product Manager, Oracle

JavaFX for desktop applications is becoming a common case. But what if JavaFX could really replace HTML (or the new HTML5)? You’d simply go to a URL and load a Website built entirely with JavaFX. Support for CSS and JavaScript would already be included, and integration with servers using WebSocket or JAX-RS RESTful services would also be supported. Pressing refresh would be an easy way to reload the application (or should we say page?) and test the new version. Could FXPs, or FX Pages, really replace HTML5? This session takes a look and considers a new approach for Web 3.0.

https://oracleus.activeevents.com/2013/connect/sessionDetail.ww?SESSION_ID=3132

XYBarChart for javafx

One new addition to the FXCharts repo that I’ve created on github. This time it’s a XYBarChart, that is a bar chart that doesn’t have the limitation of the SDK BarChart which only allows you to have a CategoryAxis/ValueAxis pair of axes.So in other words, for example,  you can’t set a pair of axes if their of type DateAxis/ValueAxis. And as another consequence of these you can’t easily add zoom capabilities to a BarChart.

These type of chart wasn’t so easy to create was one might initially expect. Copy pasting the code from BarChart and altering the significant bits is not enough since BarChart relies on several package private methods from XYChart.

You can grab it from: https://github.com/dukke/FXCharts. If you have patches, features, fixes for this library please participate. Let’s create a better charts API.

 

DateAxis for javafx

A somewhat common request for people working with the charts API in JavaFX is a DateAxis. Essentially that would be an Axis that would be able to show dates.

I’ve hacked up a quick implementation of one, you can get it from github: https://github.com/dukke/FXCharts

It takes the time value of dates and displays them using the format given defined by “TICK_UNIT_FORMATTER_DEFAULTS”.

It’s not really a very elegant solution but it works. I’ll try to give a hand to Diego Cirujano-Cuesta and Christian Schudt who are working in a more evolved DateAxis that takes up Dates instead of their time value.

This implementation was done under Java8. It might work with JavaFX 2.2, I don’t know.

What’s new in Java 8 (Part I – JavaFX)

Disclaimer: I do not work for Oracle or represent Oracle in any way. This list of features is not official. This is just part of my research as an “outsider”.

Java 8 has become feature complete about two months ago and the developer preview is just around the corner (in a couple week’s time). This blog post will detail what’s coming in this next major release with an emphasis on JavaFX 8, which is the UI library. JavaFX release number is now on par with the Java release, that’s why it has jumped from 2.2 to 8.

This is part I of a three part series of posts. This first part will focus on what Oracle has officially been telling developers that should come out in JavaFX 8, the second part will be mostly speculative, and listing what I think might come out and is not officially being reported.  And the final part focuses on the rest that’s coming to Java 8, excluding the UI library (e.g., new language features and such).

Release dates

The original schedule aimed to ship the release in early September 2013, but due to the recent focus on browser-related security issues that date was not achieved. The new schedule is as follows:

  • 2013/06/13 – Feature Complete

All features have been implemented and integrated into the master forest, together with unit tests.

  • 2013/09/05 – Developer Preview

A reasonably stable build suitable for broad testing by the developer community is published. This build will include all planned features unless otherwise stated.

  • 2014/01/23 – Final Release Candidate

The date by which the final release candidate must be declared and submitted for testing. One or more release candidates will be declared after the planned ZBB date; if another is necessary after this milestone then the General Availability  date will be at risk.

  • 2014/03/18 – General Availability

Final release, ready for production use.

To this let me add that I’ve been developing Java based apps under Java 8 for more than a month now and consider it to be quite stable. I’m also not using any of the features under development (like 3D graphics for example), so I can’t say anything for that part.

You can already get an early access release of JDK8 here: http://jdk8.java.net/download.html

On that site you can also download some sample apps, where you can get a glimpse of what’s already possible to do.Ensemble8

New Features

The following list will focus especially on the most relevant upcoming features. The list of all coming new features and changes to existing ones is particularly big in this release and it could be that some relevant ones might have escaped my attention and may not me mentioned.

Rich text support

rich textRich text support will be added in JavaFX 8 via TextFlow class.

This will allow you to:

  • Style individual words;
  • apply effects to words
  • apply transforms
  • embed nodes inside text
  • support Bidi text, that is text containing text in both text directionalities, both right-to-left (RTL) and left-to-right (LTR)
  • create text that can be individually styled via CSS

For more details visit this links:

  • Rich text API Details:

  https://wikis.oracle.com/display/OpenJDK/Rich+Text+API+Details

Swing Node

Swing node will allow you to embed swing components inside a javafx scene. Support for the opposite, that is, embedding a javafx scene inside a swing app is already possible via JFXPanel.

For the API specification and a simple example visit: http://download.java.net/jdk8/jfxdocs/javafx/embed/swing/SwingNode.html

Changes to the controls API

Several changes will occur to the controls API, this is especially important to third party control providers:

  • Skin class which will become public;

SkinBase class will become public, but Behavior class and subclasses are still private implementation, there is still some work to be done here after JavaFX 8.

Video and audio recording

Support for video and audio recording will be added.

You can watch this video presentation for more details (jump to minute 39 to see an example app in action): http://www.youtube.com/watch?v=jaPUbzfJx2A

Update: Unfortunately this won’t be available after all. It has been postpone to a later release, code named “Van Ness” – https://javafx-jira.kenai.com/browse/RT-3458

Printing support

Printing support will be added to JavaFX. You can check this detailed blog post by Carl Dea for more details: http://carlfx.wordpress.com/2013/07/15/introduction-by-example-javafx-8-printing/

New looks with a new theme called Modena

Modena

The looks have been significantly improved with a new theme called Modena. This time a lot developer feedback was taken into account making for a very nice end result.

More details can be found here:

http://fxexperience.com/2013/03/modena-theme-update/

New DatePicker and TreeTable controls

JavaFX 8 will have a DatePicker and a TreeTable control:

  • DatePicker

DatePicker UXUser experience documentation: http://openjdk.java.net/projects/openjfx/ux/datePicker/

Actual DatePicker screenshot:

datePicker screenshot

Update: Jim Weaver has written about the DatePicker control, you can find his post here – http://learnjavafx.typepad.com/weblog/2013/08/quick-and-dirty-javafx-8-datepicker-example.html

  • TreeTable

TreeTableView

API examples: https://wikis.oracle.com/display/OpenJDK/TreeTableView+API+Examples

User Experience documentation:

https://wikis.oracle.com/display/OpenJDK/TreeTableView+User+Experience+Documentation

WebView Enhancements

The following enhancements were added to WebView:

  • Nashorn JavaScript engine (Update: I didn’t mean to say Nashorn is going to be webview Javascript engine. I’m just saying Nashorn will be available for use in Java8)

Nashorn’s goal is to implement a lightweight high-performance JavaScript runtime in Java with a native JVM. This Project intends to enable Java developers embedding of JavaScript in Java applications and to develop free standing JavaScript applications. (More on this on a later post).

More information on:

https://oracleus.activeevents.com/connect/sessionDetail.ww?SESSION_ID=4082&tclass=popup

Embedded Support

JavaFX will be included in Oracle’s Java SE Embedded 8. It will include a subset of features of the desktop version, namely it will not include:

  • WebView support
  • Media support

Workaround for media:

For media there is a workaround however, as this comment in FXExperience from Jasper Potts explains:

“There is no JavaFX media support on Pi, we prototyped passing
hardware decoded frames of video into OpenGL so that it could be drawn
in JavaFX Scene but performance was not great. So what we do is draw
JavaFX with a transparent background just like a transparent window on
desktop. Then use the native omx media player to play video to a lower
layer under the JavaFX graphics. So basically standard hardware overlay
graphics. This works great on PI and there is only about a 10% drop in
JavaFX performance when playing a HD video stream underneath. So simple
animations we can get 50+ fps with video at same time.”

(source: http://fxexperience.com/2013/08/javafx-hd-menus-on-raspberrypi/)

Improved 3D support

Improved 3D support will be available in this release. Or it’s probably more accurate to say: true 3D support.

It is an optional feature, you can query the runtime to know whether it is available for the given platform. When JavaFX runs with software rendering this 3D features will not be available.

·     Movable cameras and SubScene

  • Camera is now a Node

Camera can be added to a scenegraph, its position and aim (or orientation) is set using standard transforms.

  • Addition of SubScene

Subscene is a special node that can be used to render part of a scene with a different camera.

·     3D primitives

  • Added two type of 3D shapes, extending from an abstract Shape3D base class:
    • User-defined shapes (MeshView)
    • Predefined shapes

Three commonly used predefined 3D shapes are introduced: Box, Cylinder and Sphere.

Shape3D class Hierarchy:

  • javafx.scene.Node
    • javafx.scene.shape.Shape3D (abstract)
      • javafx.scene.shape.MeshView
      • javafx.scene.shape.Box
      • javafx.scene.shape.Cylinder
      • javafx.scene.shape.Sphere

Mesh Class Hierarchy:

  • java.lang.Object
    • javafx.scene.shape.Mesh (abstract)
      • javafx.scene.shape.TriangleMesh

·     3D Attributes

  • Added lights and 3D materials to add realism for 3D shapes.

Material specifies the appearance of a 3D shape. Light interacts with the geometry of a Shape3D and its material to provide the rendering result.

A Shape 3D can be rendered either as a filled shape or as a wireframe.

·     Light

  • Light is defined as a node in the scene graph
  • There are 2 types of light sources:

AmbientLight: A light source that affects all objects equally. AmbientLight objects model the light reflected from other visual objects. If you look up at the underside of your desk, you will see the bottom surface of the desk although no light source is directly shining on that surface (unless you have a lamp under your desk). The light shining up on the bottom surface of the desk reflected off the floor and other objects. In natural environments with many objects, light reflects off many objects to provide ambient light. The AmbientLight class simulates this effect.

PointLight: A light source with a position. The distance and direction to a given object affects how this lights up the object. PointLight objects approximate bare light bulbs, candles, or other light sources without reflectors or lenses.

May add more types of lights in the future (example: spot light, a light that simulates light sources such as flash lights).

  • A scene contains a set of active lights

A default light is provided when the set of active light is empty

  • Each light contains a set of affected nodes

If a Parent is in the set, all its children are affected. The default is the root node of the Scene.

·     Material

  • Material contains a set of rendering properties
  • PhongMaterial is a concrete subclass of Material. It has the following properties:
    • Ambient color
    • Diffuse color, diffuse map
    • Specular color, specular map
    • Specular power
    • Bump map
    • Self-illumination map

·     Methods added to Node

  • A LOD helper method that returns the area of the Node projected onto the physical screen in pixel units:

public double computeAreaInScreen()

LOD stands for Level of Detail. It is technique that changes the appearance of an object depending on how close or distant to the camera it is, or in other words the level of detail is changed according to the area occupied by the object if the object is far then the detail can be lowered without the user noticing it, and thus improving performance.

  • A new set of methods that transform 3D points

·       Loader support

Many 3D file formats exist, such as:  Obj, Maya, 3D Studio Max, Collada, KRML. There will be no official 3D file format loaders shipping with the API. Oracle however will provide sample code for one or two popular formats. At least a Collada file loader is in the works.

References

Other minor features, tweaks and changes

Builders are deprecated

Builders are now deprecated in this release. In Java 9 they will be removed (this is several years down the road). You should start planning to replace builders if you are using them.

Reason:

Due to an implementation detail, Builders would stop working in Java 8 unless some binary incompatibilities were introduced. Because of that the decision was to phase out the Builders, the changes that were required would reduce the value of the builders to the point where they just wouldn’t be worth it, and when considering Mobile / Embedded use cases, the extra cost of the builders would be prohibitive. (http://mail.openjdk.java.net/pipermail/openjfx-dev/2013-March/006725.html)

Javafx thread and swing will merge

JavaFX thread and swing can be merged, this is still an experimental API and will not be public, and you’ll have to turn it on explicitly. If you are developing a hybrid Swing/JavaFX app this will simplify the code since you only have to worry about one UI thread.

You can read more about this in this blog post:

http://wiki.apidesign.org/wiki/JavaFX

JavaFX fully open sourced

JavaFX has just recently become fully open sourced. This is great news since it will allow third parties and developers to extend the functionality of JavaFX more easily and thoroughly. Also good for debugging errors, and other things.

JavaFX on the default classpath

This has been a recurring request from developers, JavaFX classes are now on the default runtime classpath for an Oracle Java implementation.