So I\'m trying to work myself into JDI. I was already successful hooking my debugger application into my debugee program by first starting the debuggee with VM commands:
It's probably because you aren't handling the subprocess stdin/stdout streams. I've got a VMLauncher utility class in my JDI scripting project that handles this; the relevant code is:
public VirtualMachine safeStart()
throws IOException,
IllegalConnectorArgumentsException,
VMStartException
{
VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
LaunchingConnector connector = vmm.defaultConnector();
Map cArgs = connector.defaultArguments();
cArgs.get("options").setValue(options);
cArgs.get("main").setValue(main);
final VirtualMachine vm = connector.launch(cArgs);
final Thread outThread = redirect("Subproc stdout",
vm.process().getInputStream(),
out);
final Thread errThread = redirect("Subproc stderr",
vm.process().getErrorStream(),
err);
if(killOnShutdown) {
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
outThread.interrupt();
errThread.interrupt();
vm.process().destroy();
}
});
}
return vm;
}
private Thread redirect(String name, InputStream in, OutputStream out) {
Thread t = new StreamRedirectThread(name, in, out);
t.setDaemon(true);
t.start();
return t;
}