JavaFX program doesn't run in nogui command li

2019-09-11 22:42发布

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

0条回答
登录 后发表回答