JavaFX 附带 JDK 8?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35974003/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 17:18:27  来源:igfitidea点击:

JavaFX comes with JDK 8?

javajavafx-8

提问by Stardust

I have multiple questions regarding JavaFX.

我有多个关于 JavaFX 的问题。

Does JavaFX come with JDK 8? Does JavaFX also require its own runtime environment?

JavaFX 是否随 JDK 8 一起提供?JavaFX 是否也需要自己的运行时环境?

I looked in my computer (I have JDK and JRE installed) but could not find the JavaFX. Does this mean that JavaFX has its own seperate runtime environment and development kit? If so, where can I find the download links?

我查看了我的计算机(我安装了 JDK 和 JRE)但找不到 JavaFX。这是否意味着 JavaFX 有自己独立的运行时环境和开发工具包?如果是这样,我在哪里可以找到下载链接?

If somehow it is already downloaded on my computer, how does JavaFX work? Is it similar to Swing or completely different?

如果它已经以某种方式下载到我的计算机上,JavaFX 是如何工作的?它是类似于 Swing 还是完全不同?



Edit Jan 2020 for those who stumble upon this question: With JDK 11, JavaFX is standalone; see jewelsea's answer below. Antonio Raposo's answer applies for JDK 8, but note that it is outdated.

为那些偶然发现这个问题的人编辑 2020 年 1 月:使用 JDK 11,JavaFX 是独立的;请参阅下面的jewelsea的回答。Antonio Raposo 的回答适用于 JDK 8,但请注意它已过时。

采纳答案by Antonio Raposo

JavaFX is bundled with JRE 8 and JDK 8. The JavaFX jar is jfxrt.jarand resides in the extfolder. To deploy an application the only requisite is that the JRE 8 is properly installed.

JavaFX 与 JRE 8 和 JDK 8 捆绑在一起。JavaFX jar 位于jfxrt.jar并驻留在ext文件夹中。要部署应用程序,唯一的必要条件是正确安装 JRE 8。

There are similarities between JavaFX and Swing, but also differences. The best way to start is by reading the documentation available at the JDK site. Be careful to read JavaFX 8 pages and not JavaFX 2 pages as there are some differences and some old examples might not work.

JavaFX 和 Swing 之间有相似之处,但也有不同之处。最好的开始方法是阅读 JDK 站点上提供的文档。请小心阅读 JavaFX 8 页面而不是 JavaFX 2 页面,因为存在一些差异并且一些旧示例可能不起作用。

You may also be interestes in one or other example I am posting in my blog A Cup of Java

您可能还对我在博客A Cup of Java 中发布的一个或其他示例感兴趣

回答by jewelsea

Update Jan 2020

2020 年 1 月更新

JDK 8 versions of JavaFX are now outdated.

JavaFX 的 JDK 8 版本现已过时。

Modern JavaFX versions (11+) are currently available from:

现代 JavaFX 版本 (11+) 目前可从以下位置获得:

JavaFX libraries are usually not shipped standard with most OpenJDK or Oracle JDK versions. Instead JavaFX is available as a seperate set of libraries, modules and a SDK. Instructions on including JavaFX with your runtime distribution and developing with JavaFX are included at the openjfx.io link above.

大多数 OpenJDK 或 Oracle JDK 版本通常不附带 JavaFX 库。相反,JavaFX 可作为一组单独的库、模块和 SDK 使用。上面的 openjfx.io 链接中包含有关在运行时分发版中包含 JavaFX 和使用 JavaFX 进行开发的说明。

Liberica JDK distributions by BellSoftcurrently ship with included JavaFX libraries and SDK tools. Or you can choose an OpenJDK version which does not include JavaFX from https://adoptopenjdk.net/and add on a JavaFX distribution via following installation instructions at https://openjfx.io/or as a maven or gradle dependency (also documented at the openjfx.io link).

BellSoft 的 Liberica JDK 发行版目前附带包含的 JavaFX 库和 SDK 工具。或者你可以选择一个OpenJDK的版本不从包括JavaFX的https://adoptopenjdk.net/,并通过在下面的安装说明上一个JavaFX分布添加https://openjfx.io/或作为行家的gradle或依赖(也记录在 openjfx.io 链接)。

JavaFX 8 tutorials hosted at Oracleare high quality and still relevant for use with later JavaFX versions.

Oracle 托管的 JavaFX 8 教程质量很高,并且仍然适用于更高的 JavaFX 版本。

Original Answer for JDK 8

JDK 8 的原始答案

JavaFX for Oracle Java 8 is not a separate installation. JavaFX is included in Oracle JDK 8running on OS X, Linux x86 and Windows. The best place to learn more about this is the Oracle Client Technologies documentation for JavaFX.

JavaFX for Oracle Java 8 不是单独的安装。JavaFX 包含在在 OS X、Linux x86 和 Windows 上运行的Oracle JDK 8 中。了解更多信息的最佳位置是JavaFXOracle Client Technologies 文档

Oracle used to distribute a binary version for Linux ARM as well, but I think that is only available by compiling the OpenJDK source now.

Oracle 过去也为 Linux ARM 分发了二进制版本,但我认为现在只能通过编译 OpenJDK 源代码来获得。

OpenJDK 8 binary installations, such as those which ship with Ubuntu, don't currently include JavaFX by default. For Ubuntu, it seems you can install a separate apt package for JavaFX. A user commented on another answer that the command for this is: sudo apt-get install openjfx(though I haven't an installation of Ubuntu to try it on). For more information on the relationship of OpenJDK and JavaFX, read: JavaFX and OpenJDK.

默认情况下,OpenJDK 8 二进制安装(例如 Ubuntu 附带的安装)当前不包含 JavaFX。对于 Ubuntu,您似乎可以为 JavaFX 安装一个单独的 apt 包。一位用户评论了另一个答案,即此命令是:(sudo apt-get install openjfx虽然我没有安装 Ubuntu 来尝试它)。有关 OpenJDK 和 JavaFX 关系的更多信息,请阅读:JavaFX 和 OpenJDK

One thing that may be confusing you is that a very early version of JavaFX (1.x) was distributed as a separate download and development kit and implemented a new language called JavaFX Script which was different from Java. However, that early version of JavaFX is now no longer supported and should not be used. As of JavaFX (2.x) the JavaFX system was completely rewritten to provide a straight Java API and no longer use JavaFX Script. As of Java 8, JavaFX was completely integrated into Oracle JDK and no longer distributed as a separate download by Oracle. Being a Java API for Java GUIs that is part of the Oracle JDK, JavaFX is similar (in that way) to Swing; so the Oracle JDK provides alternate and distinct toolkits in the form of Swing and JavaFX.

可能让您感到困惑的一件事是,JavaFX (1.x) 的早期版本作为单独的下载和开发工具包分发,并实现了一种名为 JavaFX Script 的新语言,它与 Java 不同。但是,该早期版本的 JavaFX 现在不再受支持,不应使用。从 JavaFX (2.x) 开始,JavaFX 系统被完全重写以提供直接的 Java API,不再使用 JavaFX Script。从 Java 8 开始,JavaFX 已完全集成到 Oracle JDK 中,不再由 Oracle 作为单独的下载分发。作为 Java GUI 的 Java API,它是 Oracle JDK 的一部分,JavaFX 类似于(在这方面)Swing;因此,Oracle JDK 以 Swing 和 JavaFX 的形式提供了替代且独特的工具包。