How to detect if a graphical interface is supported?

前端 未结 5 771
悲哀的现实
悲哀的现实 2021-01-01 12:20

I need my Java program to have two display modes: a GUI interface and a command line interface. If I run it in Windows, OS X, or another graphical environment I should get

5条回答
  •  一个人的身影
    2021-01-01 12:56

    I was looking for te same solution and came up with simply use an argument so when i run my program from comandline the args differs in length

    if(args.length > 0) {
        System.out.println("command line mode");
    }
    

提交回复
热议问题