Home Attaching the Java Debugger to a process called with ProcessBuilder
 This is a syntax question regarding the arguments passed to ProcessBuilder. I have a Java program that is being used to launch another Java program through ProcessBuilder. The second program is a fully compiled executable and not something I can just launch in a thread. I have no trouble launching my second program, unless I want to attach a debugger (NetBeans in this case). Normal operation looks like this: String[] pbArgs = {pathToExe, switch1, switch2, switch3}; ProcessBuilder pb = new ProcessBuilder(pbArgs); pb.start();  The trouble comes when I try to attach the debugger. When I run the second program on it's own and attach the debugger, the command string looks like this: /path/to/javaExecutable -jvmargs "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8770"  My problem seems to be, how do I format this: "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8770"  so that I can pass it to the ProcessBuilder as a string and not have ProcessBuilder tokenize it into something useless? What I'm doing that isn't working is this: String debug = "-jvmargs \"-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8770\""; String[] pbArgs = {pathToExe, switch1, switch2, switch3, debug}; ProcessBuilder pb = new ProcessBuilder(pbArgs); pb.start();  ProcessBuilder sees that space between -Xdebug and -Xrunjdwp and tokenizes. So I get this: Unknown option: -jvmargs|-Xdebug|-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8770.  Is there a way to prevent that tokenization? Any ideas?