I have a GUI program that is executed by default via javaw.exe
using a startup wrapper created with Launch4j.
This program can also be executed from command-line and then print output to the console.
How can I detect if a console is visible, hence that the text I output via System.out.println()
is visible?
From my understanding this depends on whether the program has been started via Javaw/wrapper or directly by java -jar myprog.jar
. Is there a way to distinguish both starts methods from withing the program?