JavaFX - can it really be deployed in a browser?


I have done some research on JavaFX over the last year, and even built some basic desktop apps with it.

It's described as being used to create RIAs (Rich Internet Application).

But can it really be deployed by a web browser? I have only deployed it via an executable JAR file.

How easy is it to deploy via web browser? Does it work? Does anyone have experience with this?

9/27/2016 11:58:03 PM

Accepted Answer

Update for the March 2018 Java Client Roadmap

I encourage readers interested in this question to review the following Oracle Whitepaper:

The above paper outlines the official Oracle position on related technologies (JavaFX/Swing/AWT/Applets/WebStart), the dates until which it intends to support those technologies and which of those technologies it intends to transition to open source development projects separate from the JDK and JRE.

Update for Java 9, Oct 2017

According to the Java 9 release notes:

Java Applet and WebStart functionality, including the Applet API, The Java plug-in, the Java Applet Viewer, JNLP and Java Web Start including the javaws tool are all deprecated in JDK 9 and will be removed in a future release.

So, for Java 9+, deployment of JavaFX in a browser using a Java plug-in will only be possible using deprecated technology. Oracle notes in another part of the Java 9 release notes:

Deprecates the Java Plug-in and associated applet technologies in Oracle's JDK 9 builds. While still available in JDK 9, these technologies will be considered for removal from the Oracle JDK and JRE in a future release. Applets and JavaFX applications embedded in a web page require the Java Plug-in to run. Consider rewriting these types of applications as Java Web Start or self-contained applications.

Note: Java Web Start isn't really an alternative as that is also deprecated (anyway, it's different from an application embedded and rendered within a browser page).

As an alternative which offers similar functionality, consider something like jpro, which deploys JavaFX applications in a browser without a Java plugin (jpro is currently only in closed beta, so it is not a viable solution as of October 2017, but maybe someday in the future...).

For now, I would recommend that the best way to deploy JavaFX applications is as self-contained applications, running outside a browser.

Previous answer for Java 7 and 8

JavaFx - can it really be deployed in a browser?

Yes, JavaFX applications can be deployed so that they run inside a web browser hosted html web page.

The technology which allows this to occur is the Java Plugin. This plugin is currently a NPAPI based browser plugin solution. The Java Plugin is shipped with the Oracle Java 7 Runtime Standard Environment.

Not all browsers are supported, only those listed on the JavaFX Supported Configurations page.

How easy is it to deploy via web browser?

The easiest way to deploy a JavaFX project in a web browser is:

  1. Create a new JavaFX project in NetBeans.
  2. Develop a simple HelloWorld App.
  3. Follow the instructions for Deploying your first JavaFX Application.

This is not difficult (in my opinion).

Alternatively, follow instructions on the detailed reference for Deploying JavaFX Applications (or use 3rd party tools). For many projects, using a tool other than the NetBeans IDE to perform packaging is a better approach. However, it is generally easier to let the NetBeans IDE handle deployment packaging tasks for you.

What follows is not related to answering the original question, but provides some opinions and information requested in comments on this answer.

Some Advice

There are pitfalls to deploying Java in a browser. I encourage you to do your own Google research on the subject.

In my mind, based upon the current JavaFX 2.x deployment model, for most application types that require a browser as the primary runtime container, using JavaFX is not an appropriate solution.

Examine the deployment and runtime requirements for your application. Based on your requirements, and knowledge of the JavaFX browser based execution model, decide if a browser based deployment using JavaFX technology is the correct mechanism for your application.

A couple of potential difficulties for browser embedded JavaFX applications

Some important browsers (e.g. Internet Explorer 10, iOS Safari and soon Desktop Chrome) don't permit execution of plugins using the NPAPI currently used by the Java browser plugin => some of your target users may be unable to use your application.

With a browser embedded application, you don't have complete control over the runtime on which your application executes (browser + Java runtime + plugin interface) => an application which was working when first installed may stop functioning as expected after an update to these runtime components.

Deployment Alternatives

If a browser based deployment model is not appropriate for your application, there are other ways to deploy JavaFX applications (e.g. WebStart, stand-alone jars and self-contained applications).

3/30/2018 1:13:50 AM

JavaFX - can it really be deployed in a browser?

No, not any more.

The answer used to be yes, as given in this answer, although even in 2013 when that was written the writing was on the wall. However, here in 2016 the answer is no, it cannot. Modern browsers essentially don't support NPAPI any longer (Firefox does for Java, but only until the end of the year), and NPAPI is required for the Java plugin.

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow