简体   繁体   English

使用 JavaFX 部署 NetBeans 应用程序

[英]Deploying a NetBeans application with JavaFX

I am attempting to build an application in NetBeans that can be deployed to and end user.我正在尝试在 NetBeans 中构建一个可以部署到最终用户的应用程序。 I am still pretty new to deploying projects and this is by far the most complicated one I have done so please bear with me.我对部署项目还是很陌生,这是迄今为止我做过的最复杂的项目,所以请多多包涵。 I currently have a working application in NetBeans which utilizes JDK 15 and JavaFX 15. As long as I run things inside of NetBeans everything works as intended.我目前在 NetBeans 中有一个使用 JDK 15 和 JavaFX 15 的工作应用程序。只要我在 NetBeans 中运行,一切都会按预期工作。 I have reached a point where I want to make sure I can distribute this application outside of NetBeans. To this end I did some searching and found the following tutorial.我已经到了我想确保可以在 NetBeans 之外分发此应用程序的地步。为此,我进行了一些搜索并找到了以下教程。

https:/.netbeans.org/kb/articles/javase-deploy.html https:/.netbeans.org/kb/articles/javase-deploy.html

I was able to follow the tutorial and build the example.我能够按照教程构建示例。 The build works in NetBeans, I am able to run the executable jar file in the dist folder from the command line, and I am able to run the jar file by executing it from the file explorer.该构建在 NetBeans 中运行,我能够从命令行运行 dist 文件夹中的可执行文件 jar,并且我能够通过从文件资源管理器中执行它来运行 jar 文件。 Now when I attempt to do the same process with my own project I run into the following errors.现在,当我尝试对自己的项目执行相同的过程时,我遇到了以下错误。

  1. When I attempt to run the jar file in the dist folder absolutely nothing happens.当我尝试运行 dist 文件夹中的 jar 文件时,绝对没有任何反应。
  2. When I attempt to run the jar file from the command line using the command当我尝试使用以下命令从命令行运行 jar 文件时

java -jar "C:\Workspace\HandyAndyVersion1_2\dist\HandyAndyVersion1_2.jar" java -jar "C:\Workspace\HandyAndyVersion1_2\dist\HandyAndyVersion1_2.jar"

I receive the following error,我收到以下错误,

Error: JavaFX runtime components are missing, and are required to run this application.错误:JavaFX 缺少运行时组件,并且需要运行此应用程序。

I am currently under the assumption that the first problem is a by product of the second.我目前假设第一个问题是第二个问题的副产品。 If anybody has a solution to this problem or any ideas on what I could have configured wrong please let me know and thank you all in advance.如果有人对此问题有解决方案或对我可能配置错误的任何想法,请告诉我并提前感谢大家。

To package a Java desktop application these days, you should be using the jpackage tool and optionally the jlink tool.现在,对于 package 和 Java 桌面应用程序,您应该使用jpackage工具和可选的jlink工具。 These will generate a JRE image that is packaged with the application and contains the modules you need.这些将生成与应用程序打包在一起并包含您需要的模块的 JRE 映像。

I suspect the issue you are running into is that the native libraries for JavaFX are not present.我怀疑您遇到的问题是 JavaFX 的本机库不存在。 Most distributions of JDK 15 do not contain the JavaFX modules, though some do.大多数 JDK 15 发行版不包含 JavaFX 模块,但有些包含。 (See the Full and FX bundles of the JDK from Azul and Bellsoft ). (请参阅AzulBellsoft提供的 JDK 的完整包和 FX 包)。 I find it is easier to use a JDK with JavaFX bundled rather than have to manage a separate module path during development for the jmod files of JavaFX, but that is another option.我发现使用捆绑了 JavaFX 的 JDK 比在开发 JavaFX 的 jmod 文件期间必须管理单独的模块路径更容易,但这是另一种选择。 Either method can be used with jlink to create a suitable JRE for your application that includes the JavaFX modules.任何一种方法都可以与 jlink 一起使用,为您的应用程序创建合适的 JRE,其中包括 JavaFX 模块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM