code: public static String runCommand(String command, String[] envp, File workingDir) throws IOException{
          String cmd[];
          if(OS.get().isUnix())
              cmd = new String[]{ "sh", "-c", command };
          else
              cmd = new String[]{ "cmd", "/C", command };
  
          Process p = Runtime.getRuntime().exec(cmd, envp, workingDir);
          ByteArrayOutputStream output = new ByteArrayOutputStream();
          redirectStreams(p, output, System.err);
          try{
              p.waitFor();
          }catch(InterruptedException ex){
              throw new RuntimeException("interrupted", ex);
          }
          if(p.exitValue()!=0)
              throw new IOException("exitValue is "+p.exitValue());
  
          return output.toString();
      }
docs: Runs the specified <code>command</code> in terminal (sh in *nix/cmd in windows) and
  returns the command output.
  
  @param command     complete command to be executed
  @param envp        array of strings, each element of which
  has environment variable settings in the format
  <i>name</i>=<i>value</i>, or
  <tt>null</tt> if the subprocess should inherit
  the environment of the current process.
  
  @param workingDir  the working directory of the subprocess, or
  <tt>null</tt> if the subprocess should inherit
  the working directory of the current process.
  
  @return output of the command.
  
  @throws IOException If an I/O error occurs
  
  @see #runCommand(String)