Process process = null; StringBuilder message = new StringBuilder(); List<String> commandList = new ArrayList<String>(); commandList.add("ipconfig"); commandList.add("/all"); try{ ProcessBuilder builder = new ProcessBuilder(commandList); builder.redirectErrorStream(true); //builder.directory(); process = builder.start(); BufferedReader in = new BufferedReader( new InputStreamReader(process.getInputStream())); String line = null; while ((line = in.readLine()) != null) { System.out.println(line); message.append(line + System.getProperty("line.separator")); } process.waitFor(); }catch (Exception e) { // TODO: handle exception }finally{ if (process != null) process.destroy(); } process.destroy(); System.out.println("process.exitValue():" +process.exitValue()); }