You don't need to include spaces. The ProcessBuilder will deal with that for you. Just pass in your arguments one by one, without space:

ProcessBuilder pb = new ProcessBuilder(
    dir + "library/crc",
    "-s",
    fileName,
    addressRanges);
Answer from assylias on Stack Overflow
🌐
Baeldung
baeldung.com › home › java › core java › guide to java.lang.processbuilder api
Guide to java.lang.ProcessBuilder API | Baeldung
November 26, 2025 - Process process = new ProcessBuilder("java", "-version").start(); First, we create our ProcessBuilder object passing the command and argument values to the constructor.
🌐
Tutorialspoint
tutorialspoint.com › java › lang › processbuilder_command_list.htm
Java ProcessBuilder command() Method
package com.tutorialspoint; import java.util.ArrayList; import java.util.List; public class ProcessBuilderDemo { public static void main(String[] args) { // create a new list of arguments for our process List<String> list = new ArrayList<>(); list.add("calc.exe"); // create the process builder ProcessBuilder pb = new ProcessBuilder(list); // set the command list pb.command(list); // print the new command list System.out.println(pb.command()); } }
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › ProcessBuilder.html
ProcessBuilder (Java Platform SE 8 )
April 21, 2026 - The returned value may be null -- this means to use the working directory of the current Java process, usually the directory named by the system property user.dir, as the working directory of the child process. ... Sets this process builder's working directory. Subprocesses subsequently started by this object's start() method will use this as their working directory. The argument may be null -- this means to use the working directory of the current Java process, usually the directory named by the system property user.dir, as the working directory of the child process.
🌐
Mkyong
mkyong.com › home › java › java processbuilder examples
Java ProcessBuilder examples - Mkyong.com
January 19, 2019 - ProcessBuilder processBuilder = new ProcessBuilder(); // -- Linux -- // Run a shell command processBuilder.command("bash", "-c", "ls /home/mkyong/"); // Run a shell script processBuilder.command("path/to/hello.sh"); // -- Windows -- // Run a command processBuilder.command("cmd.exe", "/c", "dir C:\\Users\\mkyong"); // Run a bat file processBuilder.command("C:\\Users\\mkyong\\hello.bat"); Process process = processBuilder.start(); 1.1 Run an external ping command to ping a website 3 times, and display the output. ... package com.mkyong.process; import java.io.BufferedReader; import java.io.IOExce
🌐
Dot Net Perls
dotnetperls.com › process-java
Java - Process, ProcessBuilder Examples - Dot Net Perls
September 16, 2024 - ProcessBuilder p = new ProcessBuilder(); // Use command "notepad.exe" and open the file. p.command("notepad.exe", "C:\\file.txt"); p.start(); } } In this example we invoke a specific executable at a known location on the computer. We concat a folder path and an executable name.
🌐
Thedeveloperblog
thedeveloperblog.com › processbuilder
Java ProcessBuilder Examples: Start Process, EXE
ProcessBuilder p = new ProcessBuilder(); // Use command "notepad.exe" and open the file. p.command("notepad.exe", "C:\\file.txt"); p.start(); } } Folder, EXE. In this example we invoke a specific executable at a known location on the computer. We concat a folder path and an executable name.
🌐
Coderanch
coderanch.com › t › 709883 › java › Add-parameters-ProcessBuilder
Add parameters to ProcessBuilder (Java in General forum at Coderanch)
May 17, 2019 - Add paramters to the ProcessBuilder. The username and the pw is always the same, thats the reason why do this automatically.
🌐
Java Tutorial HQ
javatutorialhq.com › java tutorial › java.lang › processbuilder › command(list command) method example
Java ProcessBuilder command(List command) method example
September 30, 2019 - NullPointerException can be thrown by this method if the argument is null. public ProcessBuilder command(List<String> command) The command(List<String> command) method returns this ProcessBuilder. ... Below is a java code demonstrates the use of command(List<String> command) method of ProcessBuilder class. package com.javatutorialhq.java.examples; import java.io.IOException; import java.util.ArrayList; import java.util.List; /* * This example source code demonstrates the use of * command(List command) method of Double class */ public class ProcessBuilderCommandList { public static void main(St
Find elsewhere
🌐
Oracle
docs.oracle.com › en › java › javase › 11 › docs › api › java.base › java › lang › ProcessBuilder.html
ProcessBuilder (Java SE 11 & JDK 11 )
January 20, 2026 - The returned value may be null -- this means to use the working directory of the current Java process, usually the directory named by the system property user.dir, as the working directory of the child process. ... Sets this process builder's working directory. Subprocesses subsequently started by this object's start() method will use this as their working directory. The argument may be null -- this means to use the working directory of the current Java process, usually the directory named by the system property user.dir, as the working directory of the child process.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-lang-processbuilder-class-java
Java.lang.ProcessBuilder class in Java - GeeksforGeeks
January 14, 2022 - Key = PATH, Value = /usr/bin:/bin:/usr/sbin:/sbin Key = JAVA_MAIN_CLASS_14267, Value = ProcessBuilderDemo Key = J2D_PIXMAPS, Value = shared Key = SHELL, Value = /bin/bash Key = JAVA_MAIN_CLASS_11858, Value = org.netbeans.Main Key = USER, Value = abhishekverma Key = TMPDIR, Value = /var/folders/9z/p63ysmfd797clc0468vvy4980000gn/T/ Key = SSH_AUTH_SOCK, Value = /private/tmp/com.apple.launchd.uWvCfYQWBP/Listeners Key = XPC_FLAGS, Value = 0x0 Key = LD_LIBRARY_PATH, Value = /Library/Java/JavaVirtualMachines /jdk1.8.0_121.jdk/Contents/Home/jre/lib/ amd64:/Library/Java/JavaVirtualMachines/jdk1.8.0_121
🌐
OpenJDK
openjdk.org › jeps › 8263697
JEP draft: Safer Process Launch by ProcessBuilder and Runtime.exec
The motivation for these changes ... or untrusted sources. The example below show how the application to use ProcessBuilder to avoid or mitigate those risks. To run a java Hello program with a string containing spaces use separate arguments....
🌐
Oracle
docs.oracle.com › javase › 7 › docs › api › java › lang › ProcessBuilder.html
ProcessBuilder (Java Platform SE 7 )
The returned value may be null -- this means to use the working directory of the current Java process, usually the directory named by the system property user.dir, as the working directory of the child process. ... Sets this process builder's working directory. Subprocesses subsequently started by this object's start() method will use this as their working directory. The argument may be null -- this means to use the working directory of the current Java process, usually the directory named by the system property user.dir, as the working directory of the child process.
🌐
Classpath
developer.classpath.org › doc › java › lang › ProcessBuilder.html
ProcessBuilder (GNU Classpath 0.95 Documentation)
By default, this is the working ... of the program binary followed by an arbitrary number of arguments. For example, find -type f invokes the find binary with the arguments "-type" and "f"....
🌐
OpenJDK
bugs.openjdk.org › browse › JDK-8263697
Safer Process Launch by ProcessBuilder and Runtime.exec
March 24, 2022 - ProcessBuilder already handles the encoding of arguments with space and tab to provide some measure of portability across operating systems. The application supplied quotes are not necessary and create an ambiguity about whether the quotes themselves are intended to be passed to the application or are only present to ensure the argument is passed as a single string.
🌐
javaspring
javaspring.net › blog › process-builder-java-example
Process Builder Java Example: A Comprehensive Guide — javaspring.net
For example, to run the ls command on a Unix-like system, the command list would be ["ls", "-l"]. Working Directory: The directory in which the process will be executed. By default, it is the current working directory of the Java virtual machine.
🌐
Oracle
docs.oracle.com › javase › 10 › docs › api › java › lang › ProcessBuilder.html
ProcessBuilder (Java SE 10 & JDK 10 )
The returned value may be null -- this means to use the working directory of the current Java process, usually the directory named by the system property user.dir, as the working directory of the child process. ... Sets this process builder's working directory. Subprocesses subsequently started by this object's start() method will use this as their working directory. The argument may be null -- this means to use the working directory of the current Java process, usually the directory named by the system property user.dir, as the working directory of the child process.
🌐
Krishna Kumar
krishnakumar.hashnode.dev › a-beginners-guide-to-processbuilder-in-java
how processbuilder work in java - Krishna Kumar
February 19, 2023 - This array represents the command that you want to execute, along with any arguments. ... In this example, the command "java -version" is passed as an array of strings to the ProcessBuilder constructor.
🌐
Oracle
docs.oracle.com › en › java › javase › 15 › docs › api › java.base › java › lang › ProcessBuilder.html
ProcessBuilder (Java SE 15 & JDK 15)
Modifying a process builder's attributes will affect processes subsequently started by that object's start() method, but will never affect previously started processes or the Java process itself. Most error checking is performed by the start() method. It is possible to modify the state of an object so that start() will fail. For example, setting the command attribute to an empty list will not throw an exception unless start() is invoked. Note that this class is not synchronized. If multiple threads access a ProcessBuilder instance concurrently, and at least one of the threads modifies one of the attributes structurally, it must be synchronized externally.