options = new OptionsAndArgs(CommandDispatcher.getAvailableCommands(), "--quiet", action, PID);
}
// System.out.println("Jar file at : " + options.getJarFilePath());
VirtualMachineHandler vmHandler = new VirtualMachineHandler(options);
CommandDispatcher dispatcher = new CommandDispatcher(options);
Object vm = null;
try {
vm = vmHandler.attachVirtualMachine();
dispatcher.dispatchCommand(vm, vmHandler);
} catch (Exception e) {
throw new RuntimeException("Failed to " + action + " agent in process " + PID, e);
} finally {
if (vm != null) {
try {
vmHandler.detachAgent(vm);
} catch (Exception e) {
// swallow this?
}
}
}