Fork us on GitHub

Big Changes and CEF

New update that might break some things and adds CEF
Big Changes and CEF

Big Changes and CEF

Today we released one of the biggest changes to Codename Ones simulator in ages. We added the ability to use CEF (Chrome Embedding Framework). This is currently off by default but even if you don’t use it you might feel the impact so it’s crucial that you read this post.

Updated July 31st with additional platform instructions below
Updated August 2nd with correction to the Linux install script
Updated August 4th with another correction to the Linux install script

The TL;DR

The big change for those of you who don’t care about the details is this: FX will no longer install automatically if it’s missing. That might be a good thing for some applications. But if you rely on media/web things might break in the simulator/debugger.

The short term workaround is to install a JVM that supports JavaFX out of the box such as ZuluFX and make sure your IDE uses it. Make sure it’s first in your path and that JAVA_HOME points at it.

Another option is to migrate to CEF which might not be an option right now if your needs are mostly media related. Read on for the details.

Why?

I wrote before about our desire to kick JavaFX and its problems to the curve. There’s no way around it. It’s outdated and buggy.

CEF is literally Chrome. It’s modern and up to date, so newer browser features behave as expected. It’s also easy to debug and has a lot of other great features we can use. It would also free us from some of the JVM dependencies and let us build smaller desktop apps moving forward.

The reason we really need it at this moment is support for WebRTC which isn’t available in the JavaFX version of the browser but is available in Chromium.

You can easily debug CEF BrowserComponent in Chrome by navigating to http://localhost:8088/ in Chrome

How will this Impact Me?

Hopefully you won’t run into any problem. If you’re using a JDK that doesn’t include JavaFX you might run into a problem in this transition period and things might fail. We recommend ZuluFX for now.

Once this transition period is done this should work with any JVM

By default CEF is off but you can turn it on explicitly instead of installing JavaFX.

Turn on CEF

This post was updated on July 31st with details on all platforms

When complete we will automatically download and install CEF on the first activation effectively disabling the JavaFX mode.

If the ~/.codenameone/cef directory is present we assume CEF is installed and try to load it instead of JavaFX.

Mac Install

To install manually download this file. Then perform the following command in the terminal:

unzip ~/Downloads/cef-mac.zip -d ~/.codenameone

To uninstall CEF in case of a problem do:

rm -Rf ~/.codenameone/cef

Windows Install

If you’re using Win32 download this file.

For Win64 download this file.

Open your user directory and search for the .codenameone directory. In that directory unzip the downloaded zip file. It should include a cef directory. If not make sure to unzip the content into a directory named cef.

You can uninstall it by deleting the cef directory at any time.

Linux Install

We only support 64 bit Linux at this time. If there are developers using 32 bit Linux as their desktops please let us know

Download the file this file.

Then install using:

mkdir ~/.codenameone/cef
unzip cef-linux64.zip -d ~/.codenameone/cef
chmod 755 ~/.codenameone/cef/lib/linux64/jcef_helper

To uninstall CEF in case of a problem do:

rm -Rf ~/.codenameone/cef

What’s Missing?

With the CEF pipeline media is implemented using the browser component. So videos literally play in the Chrome browser (seamlessly, you wouldn’t know). This removes the need for JavaFX completely and simplifies a lot of things.

However, there’s one missing piece at the moment: h264 support.

By default JCEF doesn’t include the h264 codec due to patent restrictions. This isn’t a problem for our use case but it means we need to get a binary build of CEF working and the build environment for Chrome is "tough". So right now h264 isn’t working.

Other than that we’re still missing Windows and Linux support. We’re also missing an installer that will deliver CEF seamlessly. All of those will ship together as part of an update in the next couple of weeks once all issues are resolved.

How does this Work?

Up until now the JavaSE port had one version which was JavaSEPort. This is now a base class for three implementations:

  • JavaFX — a compatibility mode implementation which is currently the default.

  • CEF — the new mode which will run if the cef directory is available/

  • JMF — a special case that uses Java Media Framework for media playback instead of JavaFX or JCEF. It has the advantage of being very small. It works very similarly to the CEF approach by searching for the JMF jar in the .codenameone directory and using it if it’s available. We’re not sure this is a use case worth pursuing.

On launch we pick the best option. If CEF is available under the .codenameone directory we pick that implementation. This uses the native library and integrates directly into the UI.

Up Next

Once this migration is done we’ll follow up with some posts on debugging under CEF etc. Please let us know if you run into trouble ASAP.

Share this Post:

Posted by Shai Almog

Shai is the co-founder of Codename One. He's been a professional programmer for over 25 years. During that time he has worked with dozens of companies including Sun Microsystems.
For more follow Shai on Twitter & github.