Reputation: 75
What I want to do is apply patch to my software. To apply patch, I must run a batch file which will replace the application jar file.
I will start to apply patch from the running application.
I have a batch file to run from Java. I'm using process builder to run the batch file.
In the batch file I'm closing the java application which has invoked the batch file using
taskkill /f /t /im myjavaprogram.exe
When this command is executed, I get the following output
01/09/2014 13:15:25 : Starting to apply patch.
ERROR: The process with PID 3652 (child process of PID 3564) could not be terminated.
Reason: The process cannot terminate itself.
SUCCESS: The process with PID 3564 (child process of PID 5648) has been terminated.
SUCCESS: The process with PID 5648 (child process of PID 3624) has been terminated.
The batch file which was started by the java program is started as a child process.
How can I start start the batch file process as a standalone or as a child process of explorer.exe?
Upvotes: 1
Views: 476
Reputation: 30088
You can't - at least not directly. ProcessBuilder only creates subprocesses.
Upvotes: 1
Reputation: 4864
Instead of that I can give an algorithm.
Create a class which always listens to a particular file say x.txt
,
and if that file is not exist call System.exit()
in java .
So , in batch file delete x.txt
. Then the java application will terminate.
Note : It may not be a good solution , but I given this solution since it will also work .
Upvotes: 0