Yes, you can do this using JDI - VirtualMachineManager (which you can get by calling Bootstrap.virtualMachineManager(); ), (at least one). Then you can call launch(); on this connector, which will provide you with a VM mirror for the virtual machine he creates. This mirror then allows you to remotely execute methods on this virtual machine.
You can configure as many remote virtual machines using this method as you see fit, although there is obviously a relatively large penalty for performing such actions, and this is a fair effort. If the efforts were not astronomical, I would personally defend the code to guarantee thread safety (using ThreadLocal ), and then you get rid of the need to worry about JDI (or a similar installation).
berry120
source share