0

To ensure the correct function of my Java program I need to know which other Java processes are running on the system currently that I have NOT started. How do I get information about the other running Java processes? Is it possible to terminate this Java processes from my Java application? It is NOT possible the exit the whole Java process, because that will terminate my program, too. Is it possible to write a platform independent source code?

Many thanks in advance!

1 Answers1

0

First: I assume you cant control the other java process, and you have not written it

solution 1: use platform dependant commands to kill the other process. Not safe at all.

Runtime runtime = Runtime.getRuntime();

public Process exec(String[] cmdarray);

see that: Killing a process using Java Platform independant: NO, because of precedent procedures

Solution 2, safer : use JMX , and it is platform independant

example here:How to stop java process gracefully?

Solution 3:

If you can do something with the other process: try to synchronize something (file, or else), to quit quietly.

Community
  • 1
  • 1