瀏覽代碼

backup: testing using java to run java application

Boyoung- 9 年之前
父節點
當前提交
b414230ba7
共有 6 個文件被更改,包括 406 次插入250 次删除
  1. 16 21
      src/communication/Communication.java
  2. 45 34
      src/protocols/SSCOT.java
  3. 211 0
      src/ui/CLI.java
  4. 34 195
      test/ui/TestCLI.java
  5. 50 0
      test/ui/TestCLI2.java
  6. 50 0
      test/ui/TestCLI3.java

+ 16 - 21
src/communication/Communication.java

@@ -66,7 +66,7 @@ public class Communication {
 	public Communication() {
 		mState = STATE_NONE;
 	}
-	
+
 	public void setTcpNoDelay(boolean on) {
 		if (mConnectedThread != null)
 			mConnectedThread.setTcpNoDelay(on);
@@ -165,8 +165,8 @@ public class Communication {
 			Util.debug("Waking up: " + getState());
 
 		// TODO: make this less strict
-		if (mState != STATE_CONNECTING && mState != STATE_CONNECTED
-				&& mConnectedThread == null && mConnectThread == null)
+		if (mState != STATE_CONNECTING && mState != STATE_CONNECTED && mConnectedThread == null
+				&& mConnectThread == null)
 			connect(mAddress);
 	}
 
@@ -326,14 +326,14 @@ public class Communication {
 		write("" + out.length);
 		write(out);
 	}
-	
+
 	public void write(int out) {
-		write(Util.intToBytes(out));
+		write(BigInteger.valueOf(out).toByteArray());
 	}
-	
+
 	public void write(byte[][] out) {
 		write(out.length);
-		for (int i=0; i<out.length; i++)
+		for (int i = 0; i < out.length; i++)
 			write(out[i]);
 	}
 
@@ -416,15 +416,15 @@ public class Communication {
 
 		return total;
 	}
-	
+
 	public int readInt() {
 		return new BigInteger(read()).intValue();
 	}
-	
+
 	public byte[][] readDoubleByteArray() {
 		int len = readInt();
 		byte[][] data = new byte[len][];
-		for (int i=0; i<len; i++)
+		for (int i = 0; i < len; i++)
 			data[i] = read();
 		return data;
 	}
@@ -462,7 +462,7 @@ public class Communication {
 					// This is a blocking call and will only return on a
 					// successful connection or an exception
 					socket = mmServerSocket.accept();
-					//socket.setTcpNoDelay(true);
+					// socket.setTcpNoDelay(true);
 				} catch (IOException e) {
 					Util.error("accept() failed", e);
 					break;
@@ -523,12 +523,9 @@ public class Communication {
 
 			mmSocket = new Socket();
 			/*
-			try {
-				mmSocket.setTcpNoDelay(true);
-			} catch (SocketException e) {
-				e.printStackTrace();
-			}
-			*/
+			 * try { mmSocket.setTcpNoDelay(true); } catch (SocketException e) {
+			 * e.printStackTrace(); }
+			 */
 		}
 
 		public void run() {
@@ -544,9 +541,7 @@ public class Communication {
 				try {
 					mmSocket.close();
 				} catch (IOException e2) {
-					Util.error(
-							"unable to close() socket during connection failure",
-							e2);
+					Util.error("unable to close() socket during connection failure", e2);
 				}
 				connectionFailed();
 				return;
@@ -605,7 +600,7 @@ public class Communication {
 			mmInStream = tmpIn;
 			mmOutStream = tmpOut;
 		}
-		
+
 		public void setTcpNoDelay(boolean on) {
 			if (mmSocket != null)
 				try {

+ 45 - 34
src/protocols/SSCOT.java

@@ -80,7 +80,7 @@ public class SSCOT extends Protocol {
 		int invariant = 0;
 
 		for (int i = 0; i < n; i++) {
-			if (Util.equal(v[i],  w[i])) {
+			if (Util.equal(v[i], w[i])) {
 				byte[] m = Util.xor(e[i], G.compute(p[i]));
 				output = new OutSSCOT(i, m);
 				invariant++;
@@ -94,39 +94,50 @@ public class SSCOT extends Protocol {
 
 	@Override
 	public void run(Party party, Metadata md, Forest forest) {
-		int n = 100;
-		int A = 32;
-		int FN = 5;
-		byte[][] m = new byte[n][A];
-		byte[][] a = new byte[n][FN];
-		byte[][] b = new byte[n][FN];
-		for (int i=0; i<n; i++) {
-			Crypto.sr.nextBytes(m[i]);
-			Crypto.sr.nextBytes(a[i]);
-			Crypto.sr.nextBytes(b[i]);			
-			while (Util.equal(a[i], b[i]))
-				Crypto.sr.nextBytes(b[i]);				
-		}
-		int index = Crypto.sr.nextInt(n);
-		b[index] = a[index].clone();
-
-		PreData predata = new PreData();
-		PreSSCOT presscot = new PreSSCOT(con1, con2);
-		if (party == Party.Eddie) {
-			presscot.runE(predata, n);
-			runE(predata, m, a);
-		} else if (party == Party.Debbie) {
-			presscot.runD(predata);
-			runD(predata, b);
-		} else if (party == Party.Charlie) {
-			presscot.runC();
-			OutSSCOT output = runC();
-			if (output.t == index && Util.equal(output.m_t, m[index]))
-				System.out.println("SSCOT test passed");
-			else 
-				System.err.println("SSCOT test failed");
-		} else {
-			throw new NoSuchPartyException(party+"");
+		for (int j = 0; j < 100; j++) {
+			int n = 100;
+			int A = 32;
+			int FN = 5;
+			byte[][] m = new byte[n][A];
+			byte[][] a = new byte[n][FN];
+			byte[][] b = new byte[n][FN];
+			for (int i = 0; i < n; i++) {
+				Crypto.sr.nextBytes(m[i]);
+				Crypto.sr.nextBytes(a[i]);
+				Crypto.sr.nextBytes(b[i]);
+				while (Util.equal(a[i], b[i]))
+					Crypto.sr.nextBytes(b[i]);
+			}
+			int index = Crypto.sr.nextInt(n);
+			b[index] = a[index].clone();
+
+			PreData predata = new PreData();
+			PreSSCOT presscot = new PreSSCOT(con1, con2);
+			if (party == Party.Eddie) {
+				con1.write(b);
+				con2.write(m);
+				con2.write(index);
+				presscot.runE(predata, n);
+				runE(predata, m, a);
+
+			} else if (party == Party.Debbie) {
+				b = con1.readDoubleByteArray();
+				presscot.runD(predata);
+				runD(predata, b);
+
+			} else if (party == Party.Charlie) {
+				m = con1.readDoubleByteArray();
+				index = con1.readInt();
+				presscot.runC();
+				OutSSCOT output = runC();
+				if (output.t == index && Util.equal(output.m_t, m[index]))
+					System.out.println("SSCOT test passed");
+				else
+					System.err.println("SSCOT test failed");
+
+			} else {
+				throw new NoSuchPartyException(party + "");
+			}
 		}
 	}
 }

+ 211 - 0
src/ui/CLI.java

@@ -0,0 +1,211 @@
+package ui;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.net.InetSocketAddress;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.GnuParser;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+
+import communication.Communication;
+import exceptions.NoSuchPartyException;
+import protocols.Party;
+import protocols.Protocol;
+import protocols.SSCOT;
+
+public class CLI {
+	public static final int DEFAULT_PORT = 8000;
+	public static final String DEFAULT_IP = "localhost";
+
+	public static void main(String[] args) {
+		// Setup command line argument parser
+		Options options = new Options();
+		options.addOption("config", true, "Config file");
+		options.addOption("forest", true, "Forest file");
+		options.addOption("eddie_ip", true, "IP to look for eddie");
+		options.addOption("debbie_ip", true, "IP to look for debbie");
+		options.addOption("protocol", true, "Algorithim to test");
+
+		// Parse the command line arguments
+		CommandLineParser cmdParser = new GnuParser();
+		CommandLine cmd = null;
+		try {
+			cmd = cmdParser.parse(options, args);
+		} catch (ParseException e1) {
+			e1.printStackTrace();
+		}
+
+		String configFile = cmd.getOptionValue("config", "config.yaml");
+		String forestFile = cmd.getOptionValue("forest", null);
+
+		String party = null;
+		String[] positionalArgs = cmd.getArgs();
+		if (positionalArgs.length > 0) {
+			party = positionalArgs[0];
+		} else {
+			try {
+				throw new ParseException("No party specified");
+			} catch (ParseException e) {
+				e.printStackTrace();
+				System.exit(-1);
+			}
+		}
+
+		int extra_port = 1;
+		int eddiePort1 = DEFAULT_PORT;
+		int eddiePort2 = eddiePort1 + extra_port;
+		int debbiePort = eddiePort2 + extra_port;
+
+		String eddieIp = cmd.getOptionValue("eddie_ip", DEFAULT_IP);
+		String debbieIp = cmd.getOptionValue("debbie_ip", DEFAULT_IP);
+
+		Class<? extends Protocol> operation = null;
+		String protocol = cmd.getOptionValue("protocol", "retrieve").toLowerCase();
+
+		if (protocol.equals("sscot")) {
+			operation = SSCOT.class;
+		} else {
+			System.out.println("Protocol " + protocol + " not supported");
+			System.exit(-1);
+		}
+
+		Constructor<? extends Protocol> operationCtor = null;
+		try {
+			operationCtor = operation.getDeclaredConstructor(Communication.class, Communication.class);
+		} catch (NoSuchMethodException | SecurityException e1) {
+			e1.printStackTrace();
+		}
+
+		// For now all logic happens here. Eventually this will get wrapped
+		// up in party specific classes.
+		System.out.println("Starting " + party + "...");
+
+		if (party.equals("eddie")) {
+			Communication debbieCon = new Communication();
+			debbieCon.start(eddiePort1);
+
+			Communication charlieCon = new Communication();
+			charlieCon.start(eddiePort2);
+
+			System.out.println("Waiting to establish connections...");
+			while (debbieCon.getState() != Communication.STATE_CONNECTED)
+				;
+			while (charlieCon.getState() != Communication.STATE_CONNECTED)
+				;
+			System.out.println("Connection established.");
+
+			debbieCon.write("start");
+			charlieCon.write("start");
+			debbieCon.readString();
+			charlieCon.readString();
+
+			try {
+				operationCtor.newInstance(debbieCon, charlieCon).run(Party.Eddie, configFile, forestFile);
+			} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
+					| InvocationTargetException e) {
+				e.printStackTrace();
+			}
+
+			debbieCon.write("end");
+			charlieCon.write("end");
+			debbieCon.readString();
+			charlieCon.readString();
+
+			try {
+				Thread.sleep(1000);
+			} catch (InterruptedException e) {
+				e.printStackTrace();
+			}
+			debbieCon.stop();
+			charlieCon.stop();
+
+		} else if (party.equals("debbie")) {
+			Communication eddieCon = new Communication();
+			InetSocketAddress eddieAddr = new InetSocketAddress(eddieIp, eddiePort1);
+			eddieCon.connect(eddieAddr);
+
+			Communication charlieCon = new Communication();
+			charlieCon.start(debbiePort);
+
+			System.out.println("Waiting to establish connections...");
+			while (eddieCon.getState() != Communication.STATE_CONNECTED)
+				;
+			while (charlieCon.getState() != Communication.STATE_CONNECTED)
+				;
+			System.out.println("Connection established");
+
+			eddieCon.write("start");
+			charlieCon.write("start");
+			eddieCon.readString();
+			charlieCon.readString();
+
+			try {
+				operationCtor.newInstance(eddieCon, charlieCon).run(Party.Debbie, configFile, forestFile);
+			} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
+					| InvocationTargetException e) {
+				e.printStackTrace();
+			}
+
+			eddieCon.write("end");
+			charlieCon.write("end");
+			eddieCon.readString();
+			charlieCon.readString();
+
+			try {
+				Thread.sleep(1000);
+			} catch (InterruptedException e) {
+				e.printStackTrace();
+			}
+			eddieCon.stop();
+			charlieCon.stop();
+
+		} else if (party.equals("charlie")) {
+			Communication debbieCon = new Communication();
+			Communication eddieCon = new Communication();
+			InetSocketAddress eddieAddr = new InetSocketAddress(eddieIp, eddiePort2);
+			eddieCon.connect(eddieAddr);
+			InetSocketAddress debbieAddr = new InetSocketAddress(debbieIp, debbiePort);
+			debbieCon.connect(debbieAddr);
+
+			System.out.println("Waiting to establish connections...");
+			while (eddieCon.getState() != Communication.STATE_CONNECTED)
+				;
+			while (debbieCon.getState() != Communication.STATE_CONNECTED)
+				;
+			System.out.println("Connection established");
+
+			eddieCon.write("start");
+			debbieCon.write("start");
+			eddieCon.readString();
+			debbieCon.readString();
+
+			try {
+				operationCtor.newInstance(eddieCon, debbieCon).run(Party.Charlie, configFile, forestFile);
+			} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
+					| InvocationTargetException e) {
+				e.printStackTrace();
+			}
+
+			eddieCon.write("end");
+			debbieCon.write("end");
+			eddieCon.readString();
+			debbieCon.readString();
+
+			try {
+				Thread.sleep(1000);
+			} catch (InterruptedException e) {
+				e.printStackTrace();
+			}
+			eddieCon.stop();
+			debbieCon.stop();
+
+		} else {
+			throw new NoSuchPartyException(party);
+		}
+
+		System.out.println(party + " exiting...");
+	}
+}

+ 34 - 195
test/ui/TestCLI.java

@@ -1,211 +1,50 @@
 package ui;
 
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.net.InetSocketAddress;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.GnuParser;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-
-import communication.Communication;
-import exceptions.NoSuchPartyException;
-import protocols.Party;
-import protocols.Protocol;
-import protocols.SSCOT;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
 
 public class TestCLI {
-	public static final int DEFAULT_PORT = 8000;
-	public static final String DEFAULT_IP = "localhost";
 
 	public static void main(String[] args) {
-		// Setup command line argument parser
-		Options options = new Options();
-		options.addOption("config", true, "Config file");
-		options.addOption("forest", true, "Forest file");
-		options.addOption("eddie_ip", true, "IP to look for eddie");
-		options.addOption("debbie_ip", true, "IP to look for debbie");
-		options.addOption("protocol", true, "Algorithim to test");
-
-		// Parse the command line arguments
-		CommandLineParser cmdParser = new GnuParser();
-		CommandLine cmd = null;
+		Runtime runTime = Runtime.getRuntime();
+		Process process = null;
+		String dir = System.getProperty("user.dir");
+		String binDir = dir + "\\bin";
+		String libs = dir + "\\lib\\*";
 		try {
-			cmd = cmdParser.parse(options, args);
-		} catch (ParseException e1) {
-			e1.printStackTrace();
-		}
-
-		String configFile = cmd.getOptionValue("config", "config.yaml");
-		String forestFile = cmd.getOptionValue("forest", null);
-
-		String party = null;
-		String[] positionalArgs = cmd.getArgs();
-		if (positionalArgs.length > 0) {
-			party = positionalArgs[0];
-		} else {
-			try {
-				throw new ParseException("No party specified");
-			} catch (ParseException e) {
-				e.printStackTrace();
-				System.exit(-1);
-			}
-		}
-
-		int extra_port = 1;
-		int eddiePort1 = DEFAULT_PORT;
-		int eddiePort2 = eddiePort1 + extra_port;
-		int debbiePort = eddiePort2 + extra_port;
-
-		String eddieIp = cmd.getOptionValue("eddie_ip", DEFAULT_IP);
-		String debbieIp = cmd.getOptionValue("debbie_ip", DEFAULT_IP);
-
-		Class<? extends Protocol> operation = null;
-		String protocol = cmd.getOptionValue("protocol", "retrieve").toLowerCase();
+			process = runTime.exec("java -classpath " + binDir + ";" + libs + " ui.CLI -protocol sscot eddie");
 
-		if (protocol.equals("sscot")) {
-			operation = SSCOT.class;
-		} else {
-			System.out.println("Protocol " + protocol + " not supported");
-			System.exit(-1);
+		} catch (IOException e) {
+			e.printStackTrace();
 		}
-
-		Constructor<? extends Protocol> operationCtor = null;
+		InputStream inputStream = process.getInputStream();
+		InputStreamReader isr = new InputStreamReader(inputStream);
+		InputStream errorStream = process.getErrorStream();
+		InputStreamReader esr = new InputStreamReader(errorStream);
+
+		System.out.println("STANDARD OUTPUT:");
+		int n1;
+		char[] c1 = new char[1024];
 		try {
-			operationCtor = operation.getDeclaredConstructor(Communication.class, Communication.class);
-		} catch (NoSuchMethodException | SecurityException e1) {
-			e1.printStackTrace();
-		}
-
-		// For now all logic happens here. Eventually this will get wrapped
-		// up in party specific classes.
-		System.out.println("Starting " + party + "...");
-
-		if (party.equals("eddie")) {
-			Communication debbieCon = new Communication();
-			debbieCon.start(eddiePort1);
-
-			Communication charlieCon = new Communication();
-			charlieCon.start(eddiePort2);
-
-			System.out.println("Waiting to establish connections...");
-			while (debbieCon.getState() != Communication.STATE_CONNECTED)
-				;
-			while (charlieCon.getState() != Communication.STATE_CONNECTED)
-				;
-			System.out.println("Connection established.");
-
-			debbieCon.write("start");
-			charlieCon.write("start");
-			debbieCon.readString();
-			charlieCon.readString();
-
-			try {
-				operationCtor.newInstance(debbieCon, charlieCon).run(Party.Eddie, configFile, forestFile);
-			} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
-					| InvocationTargetException e) {
-				e.printStackTrace();
-			}
-
-			debbieCon.write("end");
-			charlieCon.write("end");
-			debbieCon.readString();
-			charlieCon.readString();
-
-			try {
-				Thread.sleep(1000);
-			} catch (InterruptedException e) {
-				e.printStackTrace();
+			while ((n1 = isr.read(c1)) > 0) {
+				System.out.print(new String(Arrays.copyOfRange(c1, 0, n1)));
 			}
-			debbieCon.stop();
-			charlieCon.stop();
-
-		} else if (party.equals("debbie")) {
-			Communication eddieCon = new Communication();
-			InetSocketAddress eddieAddr = new InetSocketAddress(eddieIp, eddiePort1);
-			eddieCon.connect(eddieAddr);
-
-			Communication charlieCon = new Communication();
-			charlieCon.start(debbiePort);
-
-			System.out.println("Waiting to establish connections...");
-			while (eddieCon.getState() != Communication.STATE_CONNECTED)
-				;
-			while (charlieCon.getState() != Communication.STATE_CONNECTED)
-				;
-			System.out.println("Connection established");
-
-			eddieCon.write("start");
-			charlieCon.write("start");
-			eddieCon.readString();
-			charlieCon.readString();
-
-			try {
-				operationCtor.newInstance(eddieCon, charlieCon).run(Party.Debbie, configFile, forestFile);
-			} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
-					| InvocationTargetException e) {
-				e.printStackTrace();
-			}
-
-			eddieCon.write("end");
-			charlieCon.write("end");
-			eddieCon.readString();
-			charlieCon.readString();
-
-			try {
-				Thread.sleep(1000);
-			} catch (InterruptedException e) {
-				e.printStackTrace();
-			}
-			eddieCon.stop();
-			charlieCon.stop();
-
-		} else if (party.equals("charlie")) {
-			Communication debbieCon = new Communication();
-			Communication eddieCon = new Communication();
-			InetSocketAddress eddieAddr = new InetSocketAddress(eddieIp, eddiePort2);
-			eddieCon.connect(eddieAddr);
-			InetSocketAddress debbieAddr = new InetSocketAddress(debbieIp, debbiePort);
-			debbieCon.connect(debbieAddr);
-
-			System.out.println("Waiting to establish connections...");
-			while (eddieCon.getState() != Communication.STATE_CONNECTED)
-				;
-			while (debbieCon.getState() != Communication.STATE_CONNECTED)
-				;
-			System.out.println("Connection established");
-
-			eddieCon.write("start");
-			debbieCon.write("start");
-			eddieCon.readString();
-			debbieCon.readString();
-
-			try {
-				operationCtor.newInstance(eddieCon, debbieCon).run(Party.Charlie, configFile, forestFile);
-			} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
-					| InvocationTargetException e) {
-				e.printStackTrace();
-			}
-
-			eddieCon.write("end");
-			debbieCon.write("end");
-			eddieCon.readString();
-			debbieCon.readString();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
 
-			try {
-				Thread.sleep(1000);
-			} catch (InterruptedException e) {
-				e.printStackTrace();
+		System.out.println("STANDARD ERROR:");
+		int n2;
+		char[] c2 = new char[1024];
+		try {
+			while ((n2 = esr.read(c2)) > 0) {
+				System.err.print(new String(Arrays.copyOfRange(c2, 0, n2)));
 			}
-			eddieCon.stop();
-			debbieCon.stop();
-
-		} else {
-			throw new NoSuchPartyException(party);
+		} catch (IOException e) {
+			e.printStackTrace();
 		}
-
-		System.out.println(party + " exiting...");
 	}
+
 }

+ 50 - 0
test/ui/TestCLI2.java

@@ -0,0 +1,50 @@
+package ui;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+
+public class TestCLI2 {
+
+	public static void main(String[] args) {
+		Runtime runTime = Runtime.getRuntime();
+		Process process = null;
+		String dir = System.getProperty("user.dir");
+		String binDir = dir + "\\bin";
+		String libs = dir + "\\lib\\*";
+		try {
+			process = runTime.exec("java -classpath " + binDir + ";" + libs + " ui.CLI -protocol sscot debbie");
+
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		InputStream inputStream = process.getInputStream();
+		InputStreamReader isr = new InputStreamReader(inputStream);
+		InputStream errorStream = process.getErrorStream();
+		InputStreamReader esr = new InputStreamReader(errorStream);
+
+		System.out.println("STANDARD OUTPUT:");
+		int n1;
+		char[] c1 = new char[1024];
+		try {
+			while ((n1 = isr.read(c1)) > 0) {
+				System.out.print(new String(Arrays.copyOfRange(c1, 0, n1)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+
+		System.out.println("STANDARD ERROR:");
+		int n2;
+		char[] c2 = new char[1024];
+		try {
+			while ((n2 = esr.read(c2)) > 0) {
+				System.err.print(new String(Arrays.copyOfRange(c2, 0, n2)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+}

+ 50 - 0
test/ui/TestCLI3.java

@@ -0,0 +1,50 @@
+package ui;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+
+public class TestCLI3 {
+
+	public static void main(String[] args) {
+		Runtime runTime = Runtime.getRuntime();
+		Process process = null;
+		String dir = System.getProperty("user.dir");
+		String binDir = dir + "\\bin";
+		String libs = dir + "\\lib\\*";
+		try {
+			process = runTime.exec("java -classpath " + binDir + ";" + libs + " ui.CLI -protocol sscot charlie");
+
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		InputStream inputStream = process.getInputStream();
+		InputStreamReader isr = new InputStreamReader(inputStream);
+		InputStream errorStream = process.getErrorStream();
+		InputStreamReader esr = new InputStreamReader(errorStream);
+
+		System.out.println("STANDARD OUTPUT:");
+		int n1;
+		char[] c1 = new char[1024];
+		try {
+			while ((n1 = isr.read(c1)) > 0) {
+				System.out.print(new String(Arrays.copyOfRange(c1, 0, n1)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+
+		System.out.println("STANDARD ERROR:");
+		int n2;
+		char[] c2 = new char[1024];
+		try {
+			while ((n2 = esr.read(c2)) > 0) {
+				System.err.print(new String(Arrays.copyOfRange(c2, 0, n2)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+}