将JavaFX从jdk跨平台中删除后会不会? [英] Does JavaFX after removing it from jdk cross-platform?

查看:808
本文介绍了将JavaFX从jdk跨平台中删除后会不会?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JavaFX 11是否跨平台?正如我在openjfx.org中看到的那样,我必须下载每个平台的版本。如果是这样,我可以以任何方式以跨平台形式使用它吗?我应该为每个java版本使用每个javafx版本吗?
不要告诉我使用maven或类似的东西。我想编写一个跨平台的软件。而且每个操作系统的每个版本都没有多版本软件。我在检查操作系统后加载模块但我可以这样做吗?
任何方式都有很多跨平台的库,即使它有本机代码,为什么OpenJFX不这样做?

Does JavaFX 11 cross-platform? As i saw in openjfx.org that i have to download releases for each platform. And if so, can i in any way use it in a cross-platform form? And should i use each javafx release for each java release? Don't tell me to use maven or something like that. I want to program a cross-platform software. And not a multi-release software each release for each OS. I thout to load the modules after checking the OS but can i do that? Any way there is a lot of libraries that are cross-platform even if it have native code so why OpenJFX doesn't do that?

推荐答案

JavaFX 11不再是JDK的一部分,它现在以两种形式发布:

JavaFX 11 is not part of the JDK any more, and it is distributed now in two flavors:

  • As SDK from https://gluonhq.com/products/javafx/.
  • Via Maven Central, like https://search.maven.org/artifact/org.openjfx/javafx-controls/11/jar

下载JavaFX SDK时您必须选择平台,就像为您的平台安装JDK时一样。它在API方面仍然是跨平台的,因此您的代码在每个平台上看起来都是一样的,但它在SDK /依赖性方面是特定于平台的。

When you download the JavaFX SDK you have to choose a platform, the same as when you install the JDK for your platform. It remains cross-platform in terms of API, so your code will look the same on every platform, but it is platform-specific in terms of SDK/dependencies.

原因是与每个SDK捆绑在一起的本机库。

The reason for that is the native libraries that are bundled with each SDK.

如果您看一下三个JavaFX 11 SDK包,每个压缩包都有大约40 MB:

If you have a look at the three JavaFX 11 SDK bundles each of them zipped has around 40 MB:


  • Windows:压缩39.7 MB,dll库中64.8 MB( jfxwebkit.dll 只有59.2 MB)和15.5 MB的罐子和来源。

  • Mac:39.7 MB压缩,72.2 MB dylib库( libjfxwebkit.dylib 只有67.8 MB)和15.6 MB的jar和源。

  • Linux:43.8 MB压缩,84.9 MB in so libraries( libjfxwebkit.so 只有80.1 MB),以及15.8 MB的罐子和来源。

  • Windows: 39.7 MB zipped, 64.8 MB in dll libraries (jfxwebkit.dll only has 59.2 MB), and 15.5 MB in jars and source.
  • Mac: 39.7 MB zipped, 72.2 MB in dylib libraries (libjfxwebkit.dylib only has 67.8 MB), and 15.6 MB in jars and source.
  • Linux: 43.8 MB zipped, 84.9 MB in so libraries (libjfxwebkit.so only has 80.1 MB), and 15.8 MB in jars and source.

现在问题是:你愿意吗?捆绑三个平台合二为一?总压缩大小为120 MB,三个平台的解压缩本机库大约为220 MB?

Now the question is: would you bundle the three platforms in one? Total zipped size of 120 MB, unzipped native libraries for three platforms around 220 MB?

在openjfx-dev邮件中,有一个关于这个问题的争论列表,但我相信采取的方法是正确的。

There was a debate about this issue precisely in the openjfx-dev mailing list, but I believe the taken approach is the correct one.

如果您使用Maven / Gradle并从Maven Central检索您的依赖项,那么在Gradle上您必须为您的平台指定分类器。请参阅示例入门。 Maven在内部完成它,所以即使你没有设置分类器,它也只为你的平台下载jar。

If you use Maven/Gradle and retrieve your dependencies from Maven Central, on Gradle you have to specify the classifier for your plaform. See the Getting Started sample. Maven does it internally, so even if you don't set the classifier, it only download the jars for your platform.

所以对于你没有的常规项目使用WebView,它可能有意义,因为您将仅为您的平台下载所需的模块依赖项: javafx.base javafx.graphics javafx.controls javafx.fxml

So for a regular project where you don't use WebView, it could make sense, as you will download only the required modules dependencies for your platform: javafx.base, javafx.graphics, javafx.controls and javafx.fxml.

但是到目前为止,现在还没有可以改变的东西,你可以获得与平台无关的JavaFX API,但是使用特定于平台的JavaFX SDK /模块。

But so far, and that's not something that can be changed now, you get your platform-agnostic JavaFX API but with platform-specific JavaFX SDK/modules.

请注意,当您分发JavaFX应用程序时,您将使用Jpackager,您将为这三个不同的平台发布三个不同的版本,因此无论哪种方式,您都需要一个平台 - 具体分配。

Note that when you distribute a JavaFX application, you will use the Jpackager and you will release three different versions for the three different platforms, so either way you are in need of a platform-specific distribution.

这篇关于将JavaFX从jdk跨平台中删除后会不会?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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