Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX - can it really be deployed in a browser? [closed]

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).

http://en.wikipedia.org/wiki/Javafx

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?

http://docs.oracle.com/javafx/2/deployment/deployment_toolkit.htm

like image 282
Alexander Mills Avatar asked Sep 30 '13 19:09

Alexander Mills


People also ask

How do I deploy JavaFX on my website?

The recommended way to embed a JavaFX application into a web page or launch it from inside a web browser is to use the Deployment Toolkit library. The Deployment Toolkit provides a JavaScript API to simplify web deployment of JavaFX applications and improve the end user experience with getting the application to start.

What has replaced JavaFX?

GWT, Vaadin, Qt, JSF, and Electron are the most popular alternatives and competitors to JavaFX.

Is JavaFX good for desktop applications?

JavaFX is a very power full way of creating GUI applications for the developers who are familiar with Java, but none of any updates happened for javaFX in java newer versions. and in Java 13, some of the previous features are not included.

Is JavaFX still supported?

Oracle wrote in its Client Support Roadmap that JavaFX new fixes will continue to be supported on Java SE 8 through March 2025.


4 Answers

Update for the March 2018 Java Client Roadmap

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

  • Java Client Roadmap Update

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). Also note for those who wish to use Web Start, even though it has now been removed from Oracle JDK 11+, it is available as open source, info on this is at OpenWebStart.

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).

like image 136
jewelsea Avatar answered Oct 21 '22 05:10

jewelsea


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.

like image 36
T.J. Crowder Avatar answered Oct 21 '22 06:10

T.J. Crowder


As of 2016 you can use jpro without any browser plugin. And it even runs on mobiles.

Edit 1: The project is free for non-commercial or open source projects. A "hello world" can be found here

like image 13
KIC Avatar answered Oct 21 '22 05:10

KIC


I found solution by chance here. what was missing in my web project.

I must add this to web.xml file :

 <mime-mapping>
    <extension>jnlp</extension>
    <mime-type>application/x-java-jnlp-file</mime-type>
</mime-mapping>
like image 1
kamel2005 Avatar answered Oct 21 '22 07:10

kamel2005