title: 7zip cmd extracting using ProcessBuilder in java
body: <p>I have a problem extracting an archive to the desired category using Java 10 ProcessBuilder and 7z.exe (18.05) with command line. The exact same command works as intended when I use Windows CMD, but no longer functions when issued by my JavaFX application using ProcessBuilder:</p>
  
  <pre><code>    public static void decompress7ZipEmbedded(File source, File destination) throws IOException, InterruptedException {
      ProcessBuilder pb = new ProcessBuilder(
              getSevenZipExecutablePath(),
              EXTRACT_WITH_FULL_PATHS_COMMAND,
              quotifyPath(source.getAbsolutePath()),
              OUTPUT_DIRECTORY_SWITCH + quotifyPath(destination.getAbsolutePath())
      );
      processWithSevenZipEmbedded(pb);
  }
  
     private static void processWithSevenZipEmbedded(ProcessBuilder pb) throws IOException, InterruptedException {
      LOG.info("7-zip command issued: " + String.join(" ", pb.command()));
      Process p = pb.start();
      new Thread(new InputConsumer(p.getInputStream())).start();
      System.out.println("Exited with: " + p.waitFor());
  }
  
     public static class InputConsumer implements Runnable {
          private InputStream is;
  
          InputConsumer(InputStream is) {
              this.is = is;
          }
  
          @Override
          public void run() {
              try {
                  int value = -1;
                  while ((value = is.read()) != -1) {
                      System.out.print((char) value);
                  }
              } catch (IOException exp) {
                  exp.printStackTrace();
              }
              LOG.debug("Output stream completed");
          }
      }
  
  public static String getSevenZipExecutablePath() {
      return FileUtil.quotifyPath(getDirectory() + "7z" + "/" + "7z");
  }
  
  public static String quotifyPath(String path) {
      return '"' + path + '"';
  }
  
  public class Commands {
  
      public static final String EXTRACT_COMMAND = "e";
      public static final String EXTRACT_WITH_FULL_PATHS_COMMAND = "x";
      public static final String PACK_COMMAND = "a";
      public static final String DELETE_COMMAND = "d";
      public static final String BENCHMARK_COMMAND = "b";
      public static final String LIST_COMMAND = "l";
  
  }
  
  public class Switches {
  
      public static final String OUTPUT_DIRECTORY_SWITCH = "-o";
      public static final String RECURSIVE_SWITCH = "-r";
      public static final String ASSUME_YES = "y";
  }
  </code></pre>
  
  <p>The command looks like this:</p>
  
  <pre><code>"C:/Users/blood/java_projects/AppRack/target/classes/7z/7z" x "D:\Pulpit\AppRack Sandbox\test\something\Something 2\Something2.7z" -o"D:\Pulpit\AppRack Sandbox\Something2"
  </code></pre>
  
  <p>And the output from ProcessBuilder:</p>
  
  <pre><code>7-Zip 18.05 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2018-04-30
  
  Scanning the drive for archives:
  1 file, 59177077 bytes (57 MiB)
  
  Extracting archive: D:\Pulpit\AppRack Sandbox\test\Something\Something 2\Something2.7z
  --
  Path = D:\Pulpit\AppRack Sandbox\test\Something\Something 2\Something2.7z
  Type = 7z
  Physical Size = 5917Exited with: 0
  7077
  Headers Size = 373
  Method = LZMA2:26 LZMA:20 BCJ2
  Solid = +
  Blocks = 2
  
  
  No files to process
  Everything is Ok
  
  Files: 0
  Size:       0
  Compressed: 59177077
  </code></pre>
  
  <p>It doesn't do ANYTHING. Doesn't create a desired folder, nothing. Using CMD it works like a charm (here log from Windows 10 CMD using <strong>the same command</strong>):</p>
  
  <pre><code>7-Zip 18.05 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2018-04-30
  
  Scanning the drive for archives:
  1 file, 59177077 bytes (57 MiB)
  
  Extracting archive: D:\Pulpit\AppRack Sandbox\test\Something\Something 2\Something2.7z
  --
  Path = D:\Pulpit\AppRack Sandbox\test\Something\Something 2\Something2.7z
  Type = 7z
  Physical Size = 59177077
  Headers Size = 373
  Method = LZMA2:26 LZMA:20 BCJ2
  Solid = +
  Blocks = 2
  
  Everything is Ok
  
  Folders: 1
  Files: 5
  Size:       64838062
  Compressed: 59177077
  </code></pre>
  
  <p>Do you have any idea what causes a difference here and why it says "No files to process, everything is ok" without doing anything? I've tried already to create a folder first using File class but it doesn't seem to be an issue because the results are the same whether the destination folder exists prior to extracting or not.</p>
  
  <p>I've already tried everything that has come to my mind and I run out of ideas at the moment. Please share with me any suggestions that you may have regarding this issue. Thanks a lot.</p>