java - How can I start and stop a jar file using another jar file? -
I want to start and stop a jar file via another jar file or java class. I am able to start a jar file via this command:
runtime run = runtime.gettime (); Process process = run.exec ("java -jar setvalue.jar");
The process begins and works fine. But I can not find how I can stop that process from other Java class / jar file. I want to run the setvalue.jar file as a background process. And it is able to start and stop that other Java file and jar file is using.
Does anyone have an idea how can I do this?
One option will be in your setvalue.jar program, while creating threads running in (true) loop That keeps watching a file at a certain place and whenever this thread finds that file, then it is the system to kill the current JVM. When you want to get out of that program, create one with another Java program in "Linux" with the use of "Touch".
Comments
Post a Comment