Here you can find the source of exec(String pwd, boolean quiet, String... command)
public static int exec(String pwd, boolean quiet, String... command)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.IOException; public class Main { /** Execute command */ public static int exec(String pwd, boolean quiet, String... command) { try {//from w w w . j av a 2 s.c o m ProcessBuilder builder = new ProcessBuilder(command); builder = builder.directory(new File(pwd)); if (!quiet) builder = builder.inheritIO(); Process proc = builder.start(); return proc.waitFor(); } catch (IOException | InterruptedException e) { fatal("An error occured while running " + String.join(" ", command), e); return -1; } } /** Print fatal error and exit. */ public static <T> T fatal(String message, Exception e) { System.out.println(message); if (e != null && System.getProperty("stacktrace") != null) e.printStackTrace(); System.exit(0); return (T) null; } }