List of usage examples for java.lang ProcessBuilder ProcessBuilder
public ProcessBuilder(String... command)
From source file:Main.java
public static void main(String[] args) { // create a new list of arguments for our process String[] list = { "notepad.exe", "test.txt" }; // create the process builder ProcessBuilder pb = new ProcessBuilder(list); try {/*from w ww . j av a2s. co m*/ // start the subprocess System.out.println("Starting the process.."); pb = pb.inheritIO(); pb.start(); } catch (IOException ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { // create a new list of arguments for our process String[] list = { "notepad.exe", "test.txt" }; // create the process builder ProcessBuilder pb = new ProcessBuilder(list); try {// w w w . j a v a 2 s . c o m pb = pb.redirectError(new File("c:/")); pb.start(); } catch (IOException ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { // create a new list of arguments for our process String[] list = { "notepad.exe", "test.txt" }; // create the process builder ProcessBuilder pb = new ProcessBuilder(list); try {//from w w w. j ava2s. c o m pb = pb.redirectInput(new File("c:/")); pb.start(); } catch (IOException ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { // create a new list of arguments for our process String[] list = { "notepad.exe", "test.txt" }; // create the process builder ProcessBuilder pb = new ProcessBuilder(list); try {//from ww w . ja v a 2s . com pb.start(); System.out.println(pb.redirectInput()); } catch (IOException ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { // create a new list of arguments for our process String[] list = { "notepad.exe", "test.txt" }; // create the process builder ProcessBuilder pb = new ProcessBuilder(list); try {//w ww. ja v a 2 s.c o m pb.start(); System.out.println(pb.redirectOutput()); } catch (IOException ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { // create a new list of arguments for our process String[] list = { "notepad.exe", "test.txt" }; // create the process builder ProcessBuilder pb = new ProcessBuilder(list); try {/*from w w w. j av a 2 s.com*/ pb = pb.redirectOutput(new File("c:/")); pb.start(); } catch (IOException ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { // create a new list of arguments for our process String[] list = { "notepad.exe", "test.txt" }; // create the process builder ProcessBuilder pb = new ProcessBuilder(list); try {// w ww. ja v a 2s . co m pb = pb.redirectError(ProcessBuilder.Redirect.from(new File("c:/"))); pb.start(); } catch (IOException ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { // create a new list of arguments for our process String[] list = { "notepad.exe", "test.txt" }; // create the process builder ProcessBuilder pb = new ProcessBuilder(list); try {/* ww w . ja v a 2s. c o m*/ pb = pb.redirectOutput(ProcessBuilder.Redirect.from(new File("c:/"))); pb.start(); } catch (IOException ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { // create a new list of arguments for our process List<String> list = new ArrayList<String>(); list.add("notepad.exe"); // create the process builder ProcessBuilder pb = new ProcessBuilder(list); // get the command list System.out.println(pb.command()); }
From source file:Test.java
public static void main(String[] args) throws Exception { File commands = new File("C:/Projects/ProcessCommands.txt"); File output = new File("C:/Projects/ProcessLog.txt"); File errors = new File("C:/Projects/ErrorLog.txt"); ProcessBuilder pb = new ProcessBuilder("cmd"); System.out.println(pb.redirectInput().toString()); System.out.println(pb.redirectOutput().toString()); System.out.println(pb.redirectError().toString()); pb.redirectInput(commands);/*from w ww. j a v a 2s .co m*/ pb.redirectError(errors); pb.redirectOutput(output); System.out.println(pb.redirectInput().toString()); System.out.println(pb.redirectOutput().toString()); System.out.println(pb.redirectError().toString()); pb.start(); }