jar文件的自动模块VM选项 [英] Automatic module VM options for jar file

查看:138
本文介绍了jar文件的自动模块VM选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我目前正在尝试Java 11中的新更改,以及外部OpenJFX SDK.
但是,我想分发一个jar文件让用户自己下载所需的SDK内容并将其放入与jar相同的文件夹中的预定义文件夹中会容易得多.
现在,我问自己是否可以在不启动我的jar的情况下自动添加所需的VM选项,而无需我的程序用户使用给定的参数从控制台启动它.
在我的情况下,这些参数如下所示:"--module-path=D:\Path\JavaFX\lib" --add-modules=javafx.controls,javafx.fxml,javafx.base,javafx.media,javafx.graphics,javafx.swing,javafx.web
除了下载SDk并将其复制到文件夹之外,我是否有办法加载这些模块而不要求用户做更多的事情?我曾考虑为用户提供每个操作系统的启动脚本,但是这比启动jar还要复杂.
感谢您的帮助,我希望没有人问过这个问题,因为我找不到任何东西.

So I am currently playing around with the new changes in Java 11 and thus the external OpenJFX SDK.
However I guess it would be much easier for me to distribute one single jar file and let users download their required SDK stuff on their own and put it into a predefined folder inside the same folder as my jar.
Now I am asking myself whether it is possible to automatically add the required VM options on launch of my jar without requiring the users of my program to launch it from the console with the given arguments.
In my case these arguments would look like this: "--module-path=D:\Path\JavaFX\lib" --add-modules=javafx.controls,javafx.fxml,javafx.base,javafx.media,javafx.graphics,javafx.swing,javafx.web
Is there a way for me to load these modules without asking the user to do more than to download the SDk and copy it to the folder? I thought about supplying the users with a startup script for each OS but that is also more complicated than just launching the jar.
Any help is appreciated and I hope no one asked this already because I haven't been able to find something.

推荐答案

您尝试使用jlink启动器吗?在Windows上,您可以创建一个批处理文件来运行Java模块化应用程序. 这是模块化应用程序的推荐方法. OpenJFX.io网站上有一个教程

Did you try using a jlink launcher? On windows, you can create a batch file to run your Java modular apps. This the recommended approach for modular application. There is a tutorial on the OpenJFX.io site

这篇关于jar文件的自动模块VM选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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