Check out example codes for "java processbuilder example". It will help you in understanding the concepts better.

Code Example 1

public static void main(String[] args) {
        ProcessBuilder processBuilder = new ProcessBuilder();

        // Run this on Windows, cmd, /c = terminate after this run
        processBuilder.command("cmd.exe", "/c", "ping -n 3 google.com");

        try {
            Process process = processBuilder.start();
			//This will block other tasks
            BufferedReader reader =
                    new BufferedReader(new InputStreamReader(process.getInputStream()));
            String line;
            while ((line = reader.readLine()) != null) {
                System.out.println(line);
            }
            int exitCode = process.waitFor();
            System.out.println("\nExited with error code : " + exitCode);

        } catch (Exception e) {
            e.printStackTrace();
        } 
}

Learn ReactJs, React Native from akashmittal.com