Hi,
I wish to check whether my background B4J app is running when I start it.
I have thought of using a check file of a map with the time to handle crashes. I also tried jps -l, but couldn't get it to run as it doesn't seem to be on a java path and when I switched directories it complained about no having a jvm.cfg file. The file idea with time is OK, but when debugging with very short time between runs and plenty of crashes it is a pain.
I saw this code in stack overflow: To check whether an application is running or not using java?
I think it makes a list of java apps running on the local jvm. Trouble is I don't know how to turn it into a B4x function/class.
I use VisualVM to keep track of what programs are running etc when debugging, This is a very handy app and can be downloaded for free at:
VisualVM Download
Viz:
I am guessing this app uses a program like the one in stack exchange to produce the tree list.
Would it be possible to use the code in B4x in a suitable basic wrapper to produce a list of apps? I don't have a clue how to do this.
Best regards
Rob
I wish to check whether my background B4J app is running when I start it.
I have thought of using a check file of a map with the time to handle crashes. I also tried jps -l, but couldn't get it to run as it doesn't seem to be on a java path and when I switched directories it complained about no having a jvm.cfg file. The file idea with time is OK, but when debugging with very short time between runs and plenty of crashes it is a pain.
I saw this code in stack overflow: To check whether an application is running or not using java?
To check whether an application is running or not using java?:
boolean result = false;
String processName = "com.myapp.MyApp";
boolean running = false;
HostIdentifier hostIdentifier = new HostIdentifier("local://localhost");
MonitoredHost monitoredHost;
monitoredHost = MonitoredHost.getMonitoredHost(hostIdentifier);
Set activeVms = monitoredHost.activeVms();
for (Object activeVmId : activeVms) {
VmIdentifier vmIdentifier = new VmIdentifier("//" + String.valueOf(activeVmId) + "?mode=r");
MonitoredVm monitoredVm = monitoredHost.getMonitoredVm(vmIdentifier);
if (monitoredVm != null) {
String mainClass = MonitoredVmUtil.mainClass(monitoredVm, true);
if (mainClass.toLowerCase().equals(processName.toLowerCase())) {
running = true;
break;
}
}
}
System.out.print(running);
;
I think it makes a list of java apps running on the local jvm. Trouble is I don't know how to turn it into a B4x function/class.
I use VisualVM to keep track of what programs are running etc when debugging, This is a very handy app and can be downloaded for free at:
VisualVM Download
Viz:
I am guessing this app uses a program like the one in stack exchange to produce the tree list.
Would it be possible to use the code in B4x in a suitable basic wrapper to produce a list of apps? I don't have a clue how to do this.
Best regards
Rob