mirror of
https://github.com/corda/corda.git
synced 2025-01-03 19:54:13 +00:00
9bb3d6b972
git-subtree-dir: sgx-jvm/avian git-subtree-mainline:f978eab8d1
git-subtree-split:09e4fe60d0
60 lines
2.0 KiB
Java
60 lines
2.0 KiB
Java
package extra;
|
|
|
|
import java.lang.Runtime;
|
|
import java.lang.Process;
|
|
|
|
public class RuntimeExec {
|
|
public static void main(String[] args) throws java.io.IOException, java.lang.InterruptedException {
|
|
Runtime runtime = Runtime.getRuntime();
|
|
String ieStr = null;
|
|
String charmapStr = null;
|
|
String[] firefox = new String[2];
|
|
|
|
if(System.getProperty("os.name").equals("windows")){
|
|
System.out.println("Executing internet explorer");
|
|
ieStr = "\"c:\\program files\\internet explorer\\iexplore.exe\" http://www.google.com";
|
|
} else {
|
|
System.out.println("Executing Firefox using string");
|
|
ieStr = "firefox http://www.google.com";
|
|
}
|
|
Process ie = runtime.exec(ieStr);
|
|
|
|
if(System.getProperty("os.name").equals("windows")){
|
|
System.out.println("Executing firefox");
|
|
firefox[0] = "c:\\program files\\mozilla firefox\\firefox.exe";
|
|
firefox[1] = "http://www.google.com";
|
|
} else {
|
|
System.out.println("Executing Firefox using array");
|
|
firefox[0] = "firefox";
|
|
firefox[1] = "http://www.google.com";
|
|
}
|
|
Process ff = runtime.exec(firefox);
|
|
|
|
boolean ffSuccess = false;
|
|
boolean ieSuccess = false;
|
|
while(!(ieSuccess && ffSuccess)){
|
|
if(!ffSuccess){
|
|
try{
|
|
System.out.println("Exit value from string exec: " + ff.exitValue());
|
|
ffSuccess = true;
|
|
} catch(IllegalThreadStateException e) {}
|
|
}
|
|
if(!ieSuccess){
|
|
try{
|
|
System.out.println("Exit value from array exec: " + ie.exitValue());
|
|
ieSuccess = true;
|
|
} catch(IllegalThreadStateException e) {}
|
|
}
|
|
}
|
|
if(System.getProperty("os.name").equals("windows")){
|
|
System.out.println("Executing and waiting for charmap");
|
|
charmapStr = "c:\\windows\\system32\\charmap.exe";
|
|
} else {
|
|
System.out.println("Executing and waiting for firefox");
|
|
charmapStr = "firefox http://www.google.com";
|
|
}
|
|
Process cm = runtime.exec(charmapStr);
|
|
System.out.println("Exit value: " + cm.waitFor());
|
|
}
|
|
}
|