How to tell if Java is running as a windows service and if the -Xrs flag is being used -
one reoccurring problem our java application on windows customers running windows service without specifying java -xrs flag. way when administrator logoff windows machine java process receives termination signal , terminates causing seems random production down situation.
i add server log files , monitoring tool warning configuration problem. in order know: 1. java application running windows service ? 2. -xrs flag specified part of java.exe command ? ideas how achieve welcomed.
found how check -xrs flag, still need determine if running service:
import java.lang.management.managementfactory; import java.util.list; public class getcommandlineflags { public static void main(string[] args) { system.out.println(new getcommandlineflags().isreducedsignal()); } public boolean isreducedsignal() { list<string> flags = managementfactory.getruntimemxbean().getinputarguments(); (string flag : flags) { if ("-xrs".equals(flag)) { return true; } } return false; } }