Automatic module VM options for jar file

不打扰是莪最后的温柔 提交于 2019-12-24 20:22:24

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/52987895/automatic-module-vm-options-for-jar-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!