问题描述
我最近了解到JavaFX并未包含在Java 11中,并且对此有疑问.
I recently learned about JavaFX not being included in Java 11, and have a question about how this will work.
现在,我维护一个针对Java 8的应用程序,主要使用Swing,但使用一些JavaFX,并且拥有非开发人员用户群.其中一些用户使用的是较旧的操作系统,因此我想继续针对Java 8.
Right now, I maintain an application that targets Java 8, uses mostly Swing but some JavaFX, and has a non-developer user base. Some of those users are on older operating systems, so I'd like to continue targeting Java 8.
但是,Java 11将于下个月发布,我担心某些较新操作系统上的用户将升级到Java 11,并且该应用程序的JavaFX组件将停止工作.
However, Java 11 comes out next month, and I'm concerned that some of the users on newer operating systems will upgrade to Java 11, and the JavaFX components of the application will cease to work.
那么,如果您希望继续以Java 8为目标,但是让JavaFX适用于安装JRE 11的人员,那么最佳的前进方向是什么?我看到了几种选择,但都不是完美的选择:
So what is the best path forward if you wish to continue targeting Java 8, but have JavaFX work for those who install JRE 11? I see several options, none of which are perfect:
- 需要单独安装JavaFX.如果是这样,我需要知道哪个版本-最有可能是 https://gluonhq .com/products/javafx/?由于这是另一次安装,因此并不理想,但是我已经为没有Java的用户提供了安装Java的说明.
- 捆绑JRE和JavaFX,并具有强制使用该JRE的启动脚本.这并不理想,因为下载量会急剧增加,并且每个操作系统都需要单独下载,但是我之前发行的发行版将JRE捆绑在一起.
- 如果检测到Java 11+,则返回Swing而不是JavaFX.我可以这样做,因为我的应用程序最初是从Swing开始的,并且只迁移了一部分,但是由于我添加的新的JavaFX特定功能会丢失,因此它也没有吸引力.
- 尝试将JavaFX运行时包含为.jar文件,并手动将其加载到类路径中,也许只有在检测到Java 11+时才可以?
- Require installing JavaFX separately. If so, I'll need to know which edition - most likely the OS-specific SDK from https://gluonhq.com/products/javafx/? Not ideal since it's another install, but I already have instructions for installing Java for those who don't have it.
- Bundle a JRE and JavaFX, and have startup scripts that force the use of that JRE. Not ideal because the download size would drastically increase, and it would require separate downloads per OS, but I've made distributions that bundle a JRE before.
- Fall back on Swing instead of JavaFX if Java 11+ is detected. I could potentially do this, since my application started out as Swing and only a fraction has migrated, but it's also not attractive since the newer, JavaFX-specific functionality I've added would be lost.
- Try including the JavaFX runtime as a .jar file and loading it on the classpath manually, perhaps only if Java 11+ is detected?
我很好奇您的想法,如果有更好的选择,我就忽略了.我没想到有一天我采用JavaFX时会将JavaFX从JRE中删除!
I'm curious what your thoughts are, and if there's a better option I've overlooked. I didn't anticipate JavaFX being removed from the JRE someday when I adopted it!
推荐答案
在我看来,您要求用户在其客户端计算机上安装Java的时代已经结束.更好的解决方案是创建一个依赖于操作系统的安装程序,将所有内容与应用程序捆绑在一起.我也想知道这样的捆绑包的大小是否真的仍然重要.从YouTube下载的单个视频可能更大.相反,通过捆绑,您可以省去很多麻烦.
To my opinion the days where you asked your users to install Java on their client machines is over. The better solution is to create an operating system dependent installer which bundles everything with the application. I am also wondering if the size of such a bundle still really matters. A single video downloaded from YouTube is probably much bigger. Instead, by bundling you save yourself a lot of headaches.
这篇关于针对Java 8构建的JavaFX应用程序-如何保持Java 11的运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!