File jar = generateAgentJar();
System.out.println("Jar is " + jar.getAbsolutePath());
List<VirtualMachineDescriptor> vmds = VirtualMachine.list();
for (VirtualMachineDescriptor vmd : vmds) {
System.out.println("VM " + vmd);
VirtualMachine vm = VirtualMachine.attach(vmd);
vm.loadAgent(jar.getAbsolutePath());
vm.detach();
}
}