问题
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