Java – How to Know if Running javaw.exe vs. java.exe

javawindows

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

Best Answer

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;
Related Question