JavaFX 运行时 JAR 文件 jfxrt.jar 在 Linux 上的位置是什么? [英] What's the location of the JavaFX runtime JAR file, jfxrt.jar, on Linux?

查看:42
本文介绍了JavaFX 运行时 JAR 文件 jfxrt.jar 在 Linux 上的位置是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Eclipse Kepler 运行一些 JavaFX 代码,使用 e(fx)clipse在 Linux 机器上安装插件,使用:

I'm trying to run some JavaFX code with Eclipse Kepler, with e(fx)clipse plugin installed, on a Linux machine, using:

java version "1.7.0_21"
OpenJDK Runtime Environment (IcedTea 2.3.9) (7u21-2.3.9-5)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

我的理解是,尽管自 JDK 7u6 版本以来 JavaFX 已包含在标准 JDK 中,但 JavaFX 运行时 JAR 文件 jfxrt.jar 被故意排除在 Java 运行时路径之外,直到在 JavaFX 和其余java基础设施已经完成.为此,您必须在我们创建新 Java 项目时手动将其添加到项目构建路径库中.

My understanding is that although JavaFX has been included with the standard JDK since version JDK 7u6, the JavaFX runtime JAR file, jfxrt.jar, was left off of the Java runtime path on purpose until further testing between JavaFX and rest of the java infrastructure has been completed. For this reason you must manually add it to the project build path libraries when we create a new Java project.

我一直在以下两个目录中寻找那个 jar,但没有成功:

I've been looking for that jar in both the following directories without success:

/usr/lib/jvm/java-7-openjdk-common/jre/lib/
/usr/lib/jvm/java-7-openjdk-amd64/lib

我还应该在哪里寻找它?

Where else should I look for it?

推荐答案

2021 年 3 月更新

此答案中的先前信息现在对于更高版本的 Java 和 JavaFX(例如 Java 11+)已过时.此更新提供了更多最新版本的信息.

The previous information in this answer is now obsolete for later versions of Java and JavaFX (e.g. Java 11+). This update provides info for more recent versions.

JavaFX 现在可从 openjfx.io 或公共 Maven 存储库作为 SDK 或库集,或模块集.JavaFX 已被划分为一组依赖项,而不是与 Java 运行时一起分发的整体 jfxrt.jar 库(例如之前使用 Oracle Java 8 的情况).

JavaFX is now available from openjfx.io or the public Maven repository as an SDK or a library set, or a module set. JavaFX has been partitioned into a set of dependencies rather than a monolithic jfxrt.jar library distributed with the Java runtime (as was previously the case with Oracle Java 8 for instance).

对于 JavaFX 11+ 版本,JavaFX jar 文件(以及伴随它们的本机库)的位置将取决于您构建项目的方式.例如:

With versions 11+ of JavaFX, the location of the JavaFX jar files (and the native libraries to accompany them) will depend on how you build your project. For example:

  • 如果您使用 Maven 或 Gradle 等构建工具并指定 JavaFX 作为依赖项,则 JavaFX jar 文件将下载到您本地的 Maven 或 Gradle 存储库(与其他 maven 依赖项相同).
  • 如果您从 openjfx.io (gluon) 下载 JavaFX SDK,则 JavaFX jar文件将位于您将 SDK 解压缩到的位置.
  • If you use a build tool such as Maven or Gradle and specify JavaFX as a dependency, then the JavaFX jar files will be downloaded into your local Maven or Gradle repository (the same as other maven dependencies).
  • If you download the JavaFX SDK from openjfx.io (gluon), then the JavaFX jar files will be in the location you unzipped the SDK to.

jfxrt.jar 在 Oracle Java 7 中的位置是:

The location of jfxrt.jar in Oracle Java 7 is:

<JRE_HOME>/lib/jfxrt.jar

jfxrt.jar 在 Oracle Java 8 中的位置是:

The location of jfxrt.jar in Oracle Java 8 is:

<JRE_HOME>/lib/ext/jfxrt.jar

将取决于您安装 Oracle Java 的位置,并且可能因 Linux 发行版和安装而异.

The <JRE_HOME> will depend on where you installed the Oracle Java and may differ between Linux distributions and installations.

jfxrt.jar 不在 Linux OpenJDK 7(您正在使用的版本)中.

jfxrt.jar is not in the Linux OpenJDK 7 (which is what you are using).

一个开源包,它提供JavaFX 8 for Debian based systems,例如因为 Ubuntu 可用.要安装此软件包,必须同时安装 Debian OpenJDK 8 软件包和 Debian OpenJFX 软件包.我不运行 Debian,所以我不确定 Debian OpenJFX 包在哪里安装 jfxrt.jar.

An open source package which provides JavaFX 8 for Debian based systems such as Ubuntu is available. To install this package it is necessary to install both the Debian OpenJDK 8 package and the Debian OpenJFX package. I don't run Debian, so I'm not sure where the Debian OpenJFX package installs jfxrt.jar.

使用 Oracle Java 8.

在 Oracle Java 8 中,JavaFX 既包含在 JDK 中,又位于默认类路径中.这意味着编译器会在构建期间和运行时自动找到 JavaFX 类,当您的用户使用您的应用程序时.因此,目前使用 Oracle Java 8 是解决您问题的最佳解决方案.

With Oracle Java 8, JavaFX is both included in the JDK and is on the default classpath. This means that JavaFX classes will automatically be found both by the compiler during the build and by the runtime when your users use your application. So using Oracle Java 8 is currently the best solution to your issue.

用于 Java 8 的 OpenJDK 可能包含 JavaFX(因为用于 Java 8 的 JavaFX 现在是开源的),但是这将取决于 OpenJDK 包组装器是否选择在其发行版中包含 JavaFX 8.我希望他们这样做,因为它应该有助于消除您在问题中遇到的困惑,并且它还在 OpenJDK 中提供了更多功能.

OpenJDK for Java 8 could include JavaFX (as JavaFX for Java 8 is now open source), but it will depend on the OpenJDK package assemblers as to whether they choose to include JavaFX 8 with their distributions. I hope they do, as it should help remove the confusion you experienced in your question and it also provides a great deal more functionality in OpenJDK.

我的理解是,尽管自 JDK 7u6 版本以来 JavaFX 已包含在标准 JDK 中

My understanding is that although JavaFX has been included with the standard JDK since version JDK 7u6

是的,但只有 Oracle JDK.

Yes, but only the Oracle JDK.

与 Java 7 捆绑在一起的 JavaFX 版本不是完全开源的,因此它不能包含在 OpenJDK(这是您正在使用的)中.

The JavaFX version bundled with Java 7 was not completely open source so it could not be included in the OpenJDK (which is what you are using).

如果您需要使用 Java 7 而不是 Java 8,您可以下载 适用于 Java 7 的 Oracle JDK 并使用它.然后 JavaFX 将包含在 Java 7 中.由于 Oracle 配置 Java 7 的方式,JavaFX 不会出现在类路径中.如果您使用 Java 7,则需要将其添加到您的类路径并使用适当的 JavaFX 打包工具 允许您的用户运行您的应用程序.一些工具(例如 e(fx)clipse 和 NetBeans JavaFX 项目类型)将为您处理类路径问题和打包任务.

In you need to use Java 7 instead of Java 8, you could download the Oracle JDK for Java 7 and use that. Then JavaFX will be included with Java 7. Due to the way Oracle configured Java 7, JavaFX won't be on the classpath. If you use Java 7, you will need to add it to your classpath and use appropriate JavaFX packaging tools to allow your users to run your application. Some tools such as e(fx)clipse and NetBeans JavaFX project type will take care of classpath issues and packaging tasks for you.

这篇关于JavaFX 运行时 JAR 文件 jfxrt.jar 在 Linux 上的位置是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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