JavaFX program doesn't run in nogui command line mode

孤街浪徒 提交于 2020-01-06 21:58:50

问题


I wrote JavaFX application that can be execute in two modes. With GUI and without.

If command line command has two parameters then cli selected, else gui:

public static void main(String[] args) {
    if (args != null && args.length > 0 && args[0].equals("cli")) {
        String pathToProperties = args[1];
        Cli cli = new Cli(pathToProperties);
        cli.loadPropertiesAndGenerateApk();
    } else {
        Application.launch(args);
    }
}

In Intellij IDEA when I click Run button everything works fine.

But when I build artifacts (.jar file) and try to run in cli mode -- GUI opens:

java -jar JavaFXApp.jar cli /path/toconfig.properties

Does anybody know why?

Update: I added System.out.println(args[0]) as @fdsa asked. And see that program launch in terminal no message: https://yadi.sk/i/uwGT4EpVkDCea

来源:https://stackoverflow.com/questions/33503220/javafx-program-doesnt-run-in-nogui-command-line-mode

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