title: Don't open Java GUI when opened from a command-line
body: <p>I'm trying to achieve the following goals with the same jar file (if possible):</p>
  
  <ol>
  <li>When command line arguments get specified, run as a CLI tool (without GUI) - that one's easy</li>
  <li>When the user launches the application by double-clicking on the <code>.jar</code> file in Windows Explorer, or when launched using a double click in Nautilus, a GUI should be launched</li>
  <li>When the user launches the program from a shell within a console/terminal (e.g. <code>cmd.exe</code>, <code>zsh</code> or <code>bash</code>), usage information should be printed and the program should exit after doing so (like when running <code>program -h</code> or program --help`), without opening a GUI.</li>
  </ol>
  
  <p>A simple <code>args.length &gt; 0</code> is not sufficient for this task, as a launch without any command line arguments should be handled differently when done via the terminal (using <code>java -jar program.jar</code>) compared to when done from Windows Explorer or Nautilus.</p>
  
  <hr>
  
  <p>Is there a way of implementing the described behaviour, does my program have to check what its parent process is, or is something like this simply unfeasible/impossible?</p>