如何构建一个罐子文件,包括所有所需的Javafx模块

发布于 2025-02-12 18:23:50 字数 1354 浏览 1 评论 0原文

我有一个(非模块化的)Javafx应用程序,该应用程序从命令行运行良好,因为我给命令行的参数 - 模块path和-add-modules包含javafx模块(在我的情况下,我使用

--module-path /home/user/libs/javafx_libs --add-modules javafx.controls,javafx.fxml,javafx.web

这很好,因为我知道我在哪里安装了我的javafx文件(即/home/user/libs/javafx_libs)

但是,

  1. 不是使用某些手动提取目录的位置,而是在一个单个应用程序中使用Maven依赖性,而
  2. 任何平台特定的依赖项

没有 Maven依赖项看起来像:

<dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-controls</artifactId>
    <version>${version.javafx}</version>
</dependency>
<dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-fxml</artifactId>
    <version>${version.javafx}</version>
</dependency>
<dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-web</artifactId>
    <version>${version.javafx}</version>
</dependency>

据我了解,我必须使我的完整应用模块化,这对我来说是(另一件)新事物,但是第一个基本步骤已经完成(添加了一个module-info.java文件,并添加了“需要” - 我想构建此应用程序

  1. 以便我可以在没有这些模块路径和模块的情况下
  2. 开始 。我可以在一个单个JAR文件中构建它吗?
  3. 如何在Maven中完成这样的构建?也就是说,我需要以这种方式构建哪个插件,以及如何在Maven中配置这些插件?

我也可以通过获得一些好书(或其他出版物)的链接来帮助我。

I have a (non-modular) JavaFX application that runs well from the command line, as I give to the command line the arguments --module-path and --add-modules to include the javafx modules (in my case, I use

--module-path /home/user/libs/javafx_libs --add-modules javafx.controls,javafx.fxml,javafx.web

This works fine, because I know where I had manually installed my javafx files (i.e. in /home/user/libs/javafx_libs).

However, I now want to build it, but

  1. not using some manual extraction directory location, but using maven dependencies, and
  2. in one single application jarfile without any platform-specific dependencies.

So my maven dependencies look like :

<dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-controls</artifactId>
    <version>${version.javafx}</version>
</dependency>
<dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-fxml</artifactId>
    <version>${version.javafx}</version>
</dependency>
<dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-web</artifactId>
    <version>${version.javafx}</version>
</dependency>

As far as I understand, I have to make my complete application modular, which is (another) new thing to me, but the first basic steps have been completed (added a module-info.java file, and added it's "requires"- statements). I want to build this application so that I can start it without these module paths and module additions.

My questions are:

  1. Where can I then find the location of Maven's repository's JavaFX files,
  2. How can I build this in one single jar file, and
  3. How is such a build done in Maven? That is, which plugins do I need to build it this way, and how do I configure these plugins in Maven?

I may also be helped by getting a link to some good book (or to some other publication) where this is explained.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文