Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to kill a Java Virtual Machine from another Virtual Machine?

I have a Java application that launches another java application. The launcher has a watchdog timer and receives periodic notifications from the second VM. However, if no notifications are received then the second virtual machine should be killed and the launcher will perform some additional clean-up activities.

The question is, is there any way to do this using only java? so far I have to use some native methods to perform this operation and it is somehow ugly.

Thanks!

like image 820
Mario Ortegón Avatar asked Dec 08 '22 09:12

Mario Ortegón


1 Answers

I may be missing something but can't you call the destroy() method on the Process object returned by Runtime.exec()?

like image 148
Dave Webb Avatar answered Dec 09 '22 23:12

Dave Webb