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
I recommend adding a command line option that determines whether to use command-line or graphical user interface, because the user may want to use the command-line interface even in the environment where GUI is available.
You can also check if console device is available or not with System.console().