rogerdpack
rogerdpack

Reputation: 66711

java how to know if you're running javaw.exe vs. java.exe

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

Upvotes: 11

Views: 1920

Answers (1)

Ti Strga
Ti Strga

Reputation: 1389

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;

Upvotes: 13

Related Questions