部署 JavaFX 应用程序、创建 JAR 和自包含应用程序以及本机安装程序的最佳方法是什么 [英] What is the best way to deploy JavaFX application, create JAR and self-contained applications and native installers

查看:38
本文介绍了部署 JavaFX 应用程序、创建 JAR 和自包含应用程序以及本机安装程序的最佳方法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 IntelliJ IDEA,并且已准备好部署 JavaFX 应用程序.问题是当我生成 JAR 文件时,它不会运行,当我在命令行中运行它时,我得到一个异常 FXMLLoadException,尽管该项目在我的 IDE 中运行良好.

I'm using IntelliJ IDEA, and I have my JavaFX application ready for deployment. The problem is that when I generate the JAR file, it won't run, when I run it in the command line, I get an Exception, FXMLLoadException, although the project is working perfectly in my IDE.

Ant 任务以错误结束,搭建15分钟后,我真的不明白到底是什么问题.

Ant tasks end with errors, after 15 minutes of building, I really don't understand what's the problem exactly.

所以我的问题是以正确的方式部署 JavaFX 应用程序的正确步骤是什么,欢迎任何教程或指南.

So my question what are the right steps to deploy a JavaFX application the right way, any tutorial or guide will be welcome.

推荐答案

Java 应用程序可以通过多种方式打包.请阅读 Java 打包概述找到关于它的一切.其中一个包装是自包含Java应用程序.

A Java application can be packaged in various ways. Please go through Java Packaging Overview to find everything about it. One of the packaging is a self-contained Java application.

有多种方法可以创建这些包:

There are different ways to create these packages :

  • 使用 JDK 附带的 javapackager 工具
  • JavaFX Ant 任务
  • 用于 Maven 项目的 JavaFX Maven 插件

自包含应用程序是您的应用程序打包方式之一,并且是特定于平台的.该捆绑包包含:

Self-contained application is one the ways how your application can be packaged and is platform specific. The bundle contains :

  • 应用程序包
  • JRE 的私有副本

可用包的列表可以是 在此处找到.

A list of available bundles can be found here.

让我们看看我们可以使用的各种工具以及如何使用它们:

Let us check out the various tools available at our disposal and how to use them:

JavaPackager 工具

JavaPackager 工具是最基本的工具,可帮助您编译、打包、签名和部署 Java(FX) 应用程序,而无需编写任何其他脚本.javapackager.jar文件位于JDK安装的bin目录下.

JavaPackager Tool is the most basic tool and helps you to compile, package, sign, and deploy your Java(FX) applications, without writing any additional scripts. The javapackager.jar file is located in the bin directory of the JDK installation.

可以与它一起使用的命令列表是 此处提供.

The list of commands, that can be used with it is available here.

JavaFX Ant 任务

JavaFX Ant 任务只需为您的项目创建一个 build.xml 文件,即可帮助您打包应用程序.

JavaFX Ant Tasks helps you package your application by just creating a build.xml file for your project.

关于如何为您的项目使用 ant 脚本的一组示例可以是 在此处找到.

A set of examples on how to use ant scripts for your project can be found here.

可用于它的命令列表是 此处提供.

The list of commands that can be used for with it is available here.

JavaFX Maven 插件

JavaFX Maven Plugin利用打包java应用到maven平台的使用.您可以通过向项目添加插件来使用它来打包基于 maven 的 java 应用程序.

JavaFX Maven Plugin leverages the usage of packaging java application to the maven platform. You can use it to package your maven based java application by adding a plugin to the project.

这个插件恕我直言,如果最简单使用出来的三个.这是一个编写得非常好、易于理解的工具,并且有大量的文档.

This plugin IMHO, if the easiest to use out of the three. It is a very nicely written, easy to understand tool and has extensive documentation.

JavaFX Gradle 插件

JavaFX Gradle Plugin 也是来自 maven 插件的作者.它具有 maven 插件的所有功能,但对于 Gradle :)

JavaFX Gradle Plugin is also from the author of the maven plugin. It has all the features that the maven plugin has, but for Gradle :)

进一步阅读:

这篇关于部署 JavaFX 应用程序、创建 JAR 和自包含应用程序以及本机安装程序的最佳方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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