运行Java可运行的JAR [英] Running java runnable JAR

查看:108
本文介绍了运行Java可运行的JAR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用OpenJDK13和OpenJFX13创建了JavaFX应用程序.在Eclipse中,我制作了Runnable JAR,但除非在命令行中添加VM参数,否则它不起作用(至少在Win 10安装中).

I have created JavaFX app with OpenJDK13 and OpenJFX13. In Eclipse I have made Runnable JAR but it doesn't work (at least on my Win 10 installation) unless I add VM arguments in command line.

因此,要解决此问题,我用文本制作了* .bat文件:

So, to fix this I made *.bat file with text:

java -jar --module-path  "C:\Java\javafx-sdk-13.0.1\lib" --add-modules javafx.controls,javafx.fxml Testing.jar

以这种方式工作.但是,我想更改我的解决方案的两件事.

It working that way. But, there is 2 things about my solution I would like to change.

  1. 有什么方法可以避免在启动应用程序时显示命令提示符?
  2. 已将所需的库打包到选定的JAR中.当我删除

-模块路径"C:\ Java \ javafx-sdk-13.0.1 \ lib"

--module-path "C:\Java\javafx-sdk-13.0.1\lib"

从* .bat文件中的参数

无效.有没有办法让它工作呢?如果我正确理解,最终用户应该在可运行的JAR中拥有他所需的一切?

from arguments in *.bat file it doesn't work. Any way to make it work without this? If I understand correctly end user should have everything he need in runnable JAR?

推荐答案

创建可运行的jar是一种非常古老的技术.由于JavaFX特定于平台的本机代码,因此它们只能在您已经在其上构建它们的平台上工作.那么,为什么不全力以赴为您的平台创建一个真正的应用程序呢?可以使用EA发行的JDK 14附带的jpackage工具来完成此操作.在此处查看教程: https://github.com/dlemmermann/JPackageScriptFX .

Creating runnable jars is a very old-style technique. They would only work on the platform on which you have built them anyway due to the platform specific native code of JavaFX. So why not go the full way and create a real application for your platform? This can be done with the jpackage tool which comes with the EA release of JDK 14. Have a look here for a tutorial: https://github.com/dlemmermann/JPackageScriptFX .

这篇关于运行Java可运行的JAR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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