简体   繁体   English

如何在Swing桌面应用程序中部署JavaFX

[英]How to deploy JavaFX in Swing desktop application

I managed to embed JavaFX HTMLEditor inside a Swing desktop application using this this tutorial , locally in Eclipse all works great. 我设法在使用本教程的Swing桌面应用程序中嵌入JavaFX HTMLEditor ,在Eclipse中本地工作都很棒。

My question is how to deploy this to our customers? 我的问题是如何将其部署到我们的客户? Oracle have a tutorial for WebStart and Applet deployment but I see no information for desktop apps. Oracle有一个WebStart和Applet部署教程,但我看不到桌面应用程序的信息。

Currently I copy libs and binaries from my installed JavaFX SDK into my project and include them when I compile distribution: 目前,我将已安装的JavaFX SDK中的库和二进制文件复制到我的项目中,并在编译分发时包含它们:

/my/application/lib/javafx/lib/javafxrt.jar
/my/application/lib/javafx/bin/[dll:s from JavaFX Runtime]

But this seems very odd, there must be a better way? 但这似乎很奇怪,必须有更好的方法吗? I need some help here. 我需要一些帮助。 The thing is that during development in Eclipse I need javafxrt.jar on the classpath, so I've copied the jar file because I couldn't see any environment variable like javafx_home I could use. 问题是在Eclipse开发期间我需要在类路径上使用javafxrt.jar ,所以我复制了jar文件,因为我看不到任何像我可以使用的javafx_home这样的环境变量。 But when JavaFX is loaded it tries to load the dlls: from a relative path, that's why I also copied the dlls into my project. 但是当加载JavaFX时,它会尝试加载dll:从相对路径开始,这也是我将dll复制到项目中的原因。

This is problematic for deployment, I rather not ship 32 bits JavaFX Runtime if clients have a 64 bits JVM installed (that won't work I think). 这对于部署来说是有问题的,如果客户端安装了64位JVM,我宁愿不运送32位JavaFX运行时(我认为这不起作用)。 Currently our customers only run Windows so for the moment that's not a problem. 目前我们的客户只运行Windows,所以这不是问题。

Isn't there a way in runtime to check if JavaFX is installed or not, and if so get path to it "dynamically"? 在运行时是否有办法检查是否安装了JavaFX,如果是,那么“动态”获取它的路径? Shipping the jar file is no problem, but I'm worried about the platform dependent binaries. 运送jar文件没问题,但我担心平台依赖的二进制文件。

Update: WebStart is not an option because we bundle/install the application with an old Windows app that is the predecessor, not all functionality is ported yet so the two applications communicate with a custom made IPC protocol. 更新: WebStart不是一个选项,因为我们使用旧版Windows应用程序捆绑/安装应用程序,而不是所有功能都已移植,因此两个应用程序与定制的IPC协议进行通信。

Any help is appreciated! 任何帮助表示赞赏! Thanks in advance. 提前致谢。

Use Java Web Start to deploy the app. 使用Java Web Start部署应用程序。 JWS makes it simple to add dependent Jars & natives to the run-time class-path of an application, and can partition the download of natives by platform. JWS使得将依赖的Jars和本机添加到应用程序的运行时类路径变得简单,并且可以按平台对本机的下载进行分区。

In fact, I'd be surprised if the JavaFX API does not already offer an extension JNLP that client apps. 事实上,如果JavaFX API还没有提供客户端应用程序的扩展JNLP ,我会感到惊讶。 can simply link to in their own JNLP launch file. 可以简单地链接到他们自己的JNLP启动文件中。

Use the new JavaFX ant tasks described here . 使用此处描述的新JavaFX ant任务。 Worked fine for me. 为我工作得很好。

EDIT: Also see native packaging: https://blogs.oracle.com/talkingjavadeployment/entry/native_packaging_for_javafx 编辑:另见本机包装: https//blogs.oracle.com/talkingjavadeployment/entry/native_packaging_for_javafx

You can embed a JavaFX component in java swing application using JFXPanel (javafx.embed.swing.JFXPanel). 您可以使用JFXPanel(javafx.embed.swing.JFXPanel)在Java swing应用程序中嵌入JavaFX组件。 it is used to embedded JavaFX components in the java swing application. 它用于在java swing应用程序中嵌入JavaFX组件。 learn more about JFXPanel at https://docs.oracle.com/javase/8/javafx/api/javafx/embed/swing/JFXPanel.html 有关JFXPanel的更多信息,请访问https://docs.oracle.com/javase/8/javafx/api/javafx/embed/swing/JFXPanel.html

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

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