Related to Find absolute java.exe path programatically from java code is there any way to know if the java process you're running was started as "java.exe" vs. "javaw.exe"?
Thanks
Join Stack Overflow to learn, share knowledge, and build your career.
Related to Find absolute java.exe path programatically from java code is there any way to know if the java process you're running was started as "java.exe" vs. "javaw.exe"?
Thanks
If the VM has no Console available (say, because you started it with javaw.exe), then a call to System.console()
will return null.
edit: i.e.,
final boolean amRunningJavaW = System.console() == null;
probablyRunningJavaW
, since this isn't actually testing the executable process name. :-) And there could be other reasons why a system Console isn't available, although I don't know of any offhand.
– Ti Strga
Feb 6 '13 at 17:53
System.console()
returning null
, if your application is run with its standard out stream piped to another program (e.g. more, less) or out to a file, then System.console()
will return null
– o.comp
Apr 17 '17 at 12:31