JavaFX - 它真的可以部署在浏览器中吗? [英] JavaFX - can it really be deployed in a browser?

查看:40
本文介绍了JavaFX - 它真的可以部署在浏览器中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

去年我对 JavaFX 做了一些研究,甚至用它构建了一些基本的桌面应用程序.

它被描述为用于创建 RIA(富 Internet 应用程序).

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

但它真的可以由网络浏览器部署吗?我只是通过一个可执行的 JAR 文件部署了它.

通过网络浏览器部署有多容易?它有效吗?有没有人有这方面的经验?

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

2018 年 3 月 Java 客户端路线图更新

我鼓励对此问题感兴趣的读者阅读以下 Oracle 白皮书:

上述论文概述了 Oracle 对相关技术 (JavaFX/Swing/AWT/Applet/WebStart) 的官方立场、打算支持这些技术的日期以及打算将哪些技术过渡到开源开发项目与 JDK 和 JRE 分开.

Java 9 更新,2017 年 10 月

根据 Java 9 发行说明:

<块引用>

Java Applet 和 WebStart 功能,包括 Applet API、Java 插件、Java Applet 查看器、JNLP 和 Java Web Start(包括 javaws 工具)在 JDK 9 中均已弃用,并将在未来版本中删除.

因此,对于 Java 9+,只能使用已弃用的技术才能使用 Java 插件在浏览器中部署 JavaFX.Oracle 在 Java 9 发行说明:

<块引用>

弃用 Oracle JDK 9 版本中的 Java 插件和相关的小程序技术.虽然在 JDK 9 中仍然可用,但将考虑在未来版本中从 Oracle JDK 和 JRE 中删除这些技术.嵌入在网页中的小程序和 JavaFX 应用程序需要 Java 插件才能运行.考虑将这些类型的应用程序重写为 Java Web Start 或自包含应用程序.

注意:Java Web Start 并不是真正的替代方案,因为它也已被弃用(无论如何,它不同于在浏览器页面中嵌入和呈现的应用程序).另请注意,对于那些希望使用 Web Start 的人,即使它现在已从 Oracle JDK 11+ 中删除,它仍可作为开源获得,有关此信息的信息位于 OpenWebStart.

作为提供类似功能的替代方案,请考虑类似 jpro 之类的东西,它可以在浏览器中部署 JavaFX 应用程序,而无需Java 插件(jpro 目前仅处于封闭测试阶段,因此截至 2017 年 10 月它不是可行的解决方案,但可能在未来的某一天......).

目前,我建议部署 JavaFX 应用程序的最佳方式是 自包含应用程序,在浏览器之外运行.

<小时>

Java 7 和 8 的上一个答案

<块引用>

JavaFx - 真的可以部署在浏览器中吗?

是的,可以部署 JavaFX 应用程序,以便它们在 Web 浏览器托管的 html 网页中运行.

允许这种情况发生的技术是 Java 插件.这个插件目前是一个基于 NPAPI 的浏览器插件解决方案.Java 插件随 Oracle Java 7 运行时标准环境一起提供.>

并非所有浏览器都受支持,仅支持 JavaFX 中列出的浏览器支持的配置页面.

<块引用>

通过网络浏览器部署有多容易?

在 Web 浏览器中部署 JavaFX 项目的最简单方法是:

  1. 在 NetBeans 中创建一个新的 JavaFX 项目.
  2. 开发一个简单的 HelloWorld 应用程序.
  3. 按照部署您的第一个 JavaFX 应用程序的说明进行操作.莉>

这并不难(在我看来).

或者,按照有关部署 JavaFX 应用程序(或使用第 3 方工具).对于许多项目,使用 NetBeans IDE 以外的工具来执行打包是更好的方法.但是,让 NetBeans IDE 为您处理部署打包任务通常更容易.

<小时>

以下内容与回答原始问题无关,但提供了对此答案的评论中要求的一些意见和信息.

一些建议

在浏览器中部署 Java 存在一些缺陷.我鼓励您就该主题进行自己的 Google 研究.

在我看来,基于当前的 JavaFX 2.x 部署模型,对于大多数需要浏览器作为主要运行时容器的应用程序类型,使用 JavaFX 不是一个合适的解决方案.

检查您的应用程序的部署和运行时要求.根据您的要求和基于 JavaFX 浏览器的执行模型的知识,确定使用 JavaFX 技术的基于浏览器的部署是否适合您的应用程序.

浏览器嵌入式 JavaFX 应用程序的一些潜在困难

一些重要的浏览器(例如 InternetExplorer 10iOS Safari 以及即将推出的 Desktop Chrome) 不允许使用当前使用的 NPAPI 执行插件Java 浏览器插件 => 您的某些目标用户可能无法使用您的应用程序.

使用浏览器嵌入式应用程序,您无法完全控制应用程序执行的运行时(浏览器 + Java 运行时 + 插件接口)=> 首次安装时运行的应用程序可能会在安装后停止按预期运行更新这些运行时组件.

部署替代方案

如果基于浏览器的部署模型不适合您的应用程序,还有其他方法可以部署 JavaFX 应用程序(例如 WebStart、独立 jar 和自包含应用程序).

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

解决方案

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

这篇关于JavaFX - 它真的可以部署在浏览器中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆