1

What is the best way to create application that can be used both as GUI app and console tool?

Here is relative info: Can one executable be both a console and GUI application?

My question is more about Java, Maven, JavaFX - my app currently runs as JavaFX GUI application.

P.S. Any relative help, very appreciated. I am totally confused.

Community
  • 1
  • 1
Constantine
  • 1,802
  • 3
  • 23
  • 37

1 Answers1

10

Probably do this:

  1. Add an option like java -jar MyApp.jar -gui
  2. Fall back to console if no GUI is available, e.g. Java runs in headless mode
  3. Use the Console class for the console ui.
PeterMmm
  • 24,152
  • 13
  • 73
  • 111
  • Is there any options to use builded with Maven javaFX .exe file with console? System.console() returns _null_ . I need somehow attach console to a process. – Constantine Aug 12 '15 at 09:38
  • 1
    `System.console() returns null` may be due to run your code from IDE: http://stackoverflow.com/questions/26078106/system-console-gives-nullpointerexception-in-netbeans – PeterMmm Aug 12 '15 at 14:13