2

I have a file jav1.jar. If I run it it downloads jav2.jar from internet and then it starts with

Process sp = Runtime.getRuntime().exec("cmd /c start javaw -jar jav2.jar");

What do I need to do in order to terminate jav1.jar but keep jav2.jar running?

Is it possible? I still can not do it. I dont know how to terminate jav1.jar.

System.exit(0); does nothing. When I terminate jav2.jar from task manager, it will also terminate jav1.jar.

Also If I correctly terminate jav2.jar, jav1.jar will close.

Does anybody have a solution?

Lorenzo Marcon
  • 8,029
  • 5
  • 38
  • 63
  • 3
    Take a look at [this](http://stackoverflow.com/questions/931536/how-do-i-launch-a-completely-independent-process-from-a-java-program). – Chris Forrence Jan 23 '14 at 14:53
  • 1
    Why? Why not just import `jav2.jar` into the classpath and run the classes in it? – Boris the Spider Jan 23 '14 at 14:53
  • in linux if you add "&" at the end of the command you will run the new process like asynchronously – Houcem Berrayana Jan 23 '14 at 14:56
  • Im not sure what you think by import into the classpath. Boris The Spider – user3228247 Jan 23 '14 at 15:01
  • 1
    @user3228247 I believe [this answer](http://stackoverflow.com/a/402570/877472) illustrates (I think) how to implement what Boris is talking about. Basically, he is suggestion to combine both processes (your jav1 and jav2) into one process to avoid the situation you described. Your application would download the jar as you described, and then it would import all the classes from that jar into the application, and invoke whatever method is required in order to start up the jav2 stuff. – Paul Richter Jan 23 '14 at 17:04
  • It seems i can get you throught the correct path.Please provide the full execution code after **Process sp = Runtime.getRuntime().exec("cmd /c start javaw -jar jav2.jar");** because i want to know what are you doing with sp variable(i.e,Process class). – ShihabSoft Apr 16 '14 at 17:34

0 Answers0