如何找出JavaFX版本 [英] How to find out JavaFX version

查看:933
本文介绍了如何找出JavaFX版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这应该很容易,但是我不知道如何做到. 有什么方法可以找出安装了哪个JavaFX版本.我不是要通过System.getProperty("javafx.runtime.version")进行编程,尽管安装了JavaFX,它仍会在我的计算机上返回一个空字符串.

This should be easy, but I can't figure out how. Is there any way to find out which JavaFX version is installed. And I DON'T mean programmatically via System.getProperty("javafx.runtime.version") , which returns an empty string on my computer, although JavaFX is installed.

我想在控制台上安装类似java -version的东西,但是为了获得JavaFX版本.

I would rather like to have something like java -version on console, but in order to get the JavaFX version.

或者,只需知道是否安装了JavaFX就足够了.我只有一些无法运行我的swing/javaFX应用程序的客户,想告诉他们检查是否已安装JavaFX.

Alternatively it would be sufficient to know if JavaFX is installed at all. I just have some customers who can't run my swing/javaFX app and would like to tell them to check whether JavaFX is installed.

推荐答案

您不能像使用Java运行时那样真正地做到这一点.区别在于java是启动JVM的计算机可执行文件. JavaFX只是一组库类.从某种意义上说,它实际上不是可执行文件.

You can't really do this the same way you do with the Java runtime. The difference is that java is a machine executable that launches the JVM. JavaFX is just a set of library classes; it's not really an executable in the same sense.

看起来您可以在运行时读取的System属性保留在jre/lib/javafx.properties中,因此您可以执行类似的操作

It looks like the System property that you can read at runtime is kept in jre/lib/javafx.properties, so you can do something like

cat $JAVA_HOME/jre/lib/javafx.properties

或Windows等效的任何版本(如果您在Windows上运行).但是,如果您在运行时获得的System属性为空,那么我怀疑此文件不存在.正如dfeuer所说,了解您的JRE版本会有所帮助.

or whatever the Windows equivalent is, if you're running on Windows. However, if the System property you get at runtime is blank, then I suspect this file doesn't exist. As dfeuer commented, it would help to know your JRE version.

更新: JDK/JRE版本与JavaFX版本之间的关系如下.

Update: The relationship between JDK/JRE version and JavaFX version is as follows.

从JRE 1.7.0更新6开始,JavaFX已包含在JRE中,但未包含在类路径中.因此,对于JRE 1.7.0,更新6和更高版本,jfxrt.jar文件包含在JAVA_HOME/jre/lib中.包含JavaFX版本信息的javafx.properties文件位于同一目录中,尽管从理论上讲,至少JRE版本将确定JavaFX版本(因为它们一起发货).

Beginning with JRE 1.7.0 update 6, JavaFX was included with the JRE, but was not on the classpath. So for JRE 1.7.0, update 6 and later, the jfxrt.jar file is included in JAVA_HOME/jre/lib. The javafx.properties file which contains the JavaFX version information is in the same directory, though in theory at least the JRE version will determine the JavaFX version (since they were shipped together).

只需检查我已安装在计算机上的JDK 1.7.0版本,从JDK版本到JavaFX版本的映射为:

Just inspecting the JDK 1.7.0 versions I have installed on my machine, the mapping from JDK version to JavaFX version is:

/Library/Java/JavaVirtualMachines/jdk1.7.0_06.jdk   javafx.runtime.version=2.2.0
/Library/Java/JavaVirtualMachines/jdk1.7.0_10.jdk   javafx.runtime.version=2.2.4
/Library/Java/JavaVirtualMachines/jdk1.7.0_11.jdk   javafx.runtime.version=2.2.4
/Library/Java/JavaVirtualMachines/jdk1.7.0_13.jdk   javafx.runtime.version=2.2.5
/Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk   javafx.runtime.version=2.2.7
/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk   javafx.runtime.version=2.2.21
/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk   javafx.runtime.version=2.2.25
/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk   javafx.runtime.version=2.2.40
/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk   javafx.runtime.version=2.2.45

从JRE 1.8.0开始,JavaFX包含在JRE中,并放置在类路径中;因此,它实际上是核心库的完整部分.在版本1.8.0中,jfxrt.jar文件位于JAVA_HOME/jre/lib/ext中(这自动使它成为类路径的一部分).包含JavaFX版本信息的javafx.properties文件仍在JAVA_HOME/jre/lib中. JavaFX在1.8.0版中的版本编号(似乎出现)只是模仿了JRE版本:

Beginning with JRE 1.8.0, JavaFX was included with the JRE and was placed on the classpath; so it's effectively a full part of the core libraries. In version 1.8.0, the jfxrt.jar file is in JAVA_HOME/jre/lib/ext (which automatically makes it part of the classpath). The javafx.properties file which contains the JavaFX version information is still in JAVA_HOME/jre/lib. The version numbering for JavaFX in version 1.8.0 (appears to) simply mimic the JRE version:

/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk  javafx.runtime.version=8.0.0
/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk   javafx.runtime.version=8.0.5
/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk   javafx.runtime.version=8.0.20

因此,对于您的客户,您可以简单地要求他们执行java -version,并且在大多数情况下,您可以推断出JavaFX版本.在极少数情况下,您可能需要更深入地挖掘.

So with your customers, you can simply ask them to do java -version and for the most part, you'll be able to deduce the JavaFX version. On some rare occasions you may need to dig a little deeper.

与之相关的注释:如果要向客户交付应用程序,并且需要确定特定版本,请考虑使用

A sort-of-related note: if you are shipping an application to customers and you need to determine a specific version, consider using a self contained application, in which you include a JRE (and JavaFX runtime) with the application.

这篇关于如何找出JavaFX版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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