java.lang.Process Java Examples

The following examples show how to use java.lang.Process. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DaCapoClientRunner.java    From dacapobench with Apache License 2.0 7 votes vote down vote up
public static void initialize(String carName, String size, int numThreads, boolean useBeans) {
  try {

    car = carName;

    /* Calling this function directly does not launch the client now. According to testing, it seems the getMain method of boot does not work properlly.
       Thus these ugly codes are temporarily used fot verifing that the whole framework works
       Will be changed once the problem is fixed
    */
    //ClientCLI.main(new String[] { car, "-i", "-t", numThreads + "", "-s", size, useBeans ? "-b" : "" });


    gero = System.getProperty("org.apache.geronimo.home.dir");
    String jhome= System.getProperty("java.home");
    ProcessBuilder pb = new ProcessBuilder(jhome + "/bin/java", "-jar", "-Dkaraf.startLocalConsole=false",gero + "/bin/client.jar", car, "-i", "-t", numThreads + "", "-s", size, useBeans ? "-b" : "");
    Process p = pb.start();
    p.waitFor();

  } catch (Exception e) {
    System.err.print("Exception initializing client: " + e.toString());
    e.printStackTrace();
    System.exit(-1);
  }
}
 
Example #2
Source File: ProcessManager.java    From jdk9-jigsaw with Creative Commons Zero v1.0 Universal 6 votes vote down vote up
public List<String> allProcesses() {
	List<String> processes = new LinkedList<String>();
	try {
	    String line;
	    Process p = null;
	    if(System.getProperty("os.name").toLowerCase().contains("win")) {
		    p = Runtime.getRuntime().exec
		    	    (System.getenv("windir") +"\\system32\\"+"tasklist.exe");
	    } else {
		    p = Runtime.getRuntime().exec("ps -e");
	    }
	    BufferedReader input =
	            new BufferedReader(new InputStreamReader(p.getInputStream()));
	    while ((line = input.readLine()) != null) {
	    	processes.add(line);
	    }
	    input.close();
	} catch (Exception err) {
	    err.printStackTrace();
	}
	
	return processes;
}
 
Example #3
Source File: EnvInfo.java    From spring-rest with Apache License 2.0 6 votes vote down vote up
final

  public static Map<String,String> mapEnvInfo(String filter) throws IOException {
      Process proc = Runtime.getRuntime().exec("env");
      Map<String, String> ret = new HashMap<>();
            try (InputStream stream = proc.getInputStream()) {
          try (Scanner s = new Scanner(stream).useDelimiter("\\n")) {
        	  while (s.hasNext())
        	  {
                  String val =  s.next();
                  String[] nameVal = val.split("=");
                  if (filter.equalsIgnoreCase("*"))
                	  ret.put(nameVal[0],nameVal.length > 1 ? nameVal[1] : "");
                  else
                  {
                	  if (nameVal[0].startsWith(filter))
                	  {
                    	  ret.put(nameVal[0],nameVal.length > 1 ? nameVal[1] : "");
                	  }
                  }
                  
        	  }
          } 
      } 
      return ret;
  }
 
Example #4
Source File: WifiUtil.java    From ShareBox with Apache License 2.0 6 votes vote down vote up
public static ArrayList<String> nativeGetConnectedIP(String deviceName) {
        ArrayList<String> connectedIP = new ArrayList<String>();
        try {
            Process local=Runtime.getRuntime().exec("cat /proc/net/arp");

            DataInputStream os=new DataInputStream(local.getInputStream());

            String line;
            Log.i(TAG,"arp begin");
            while ((line = os.readLine()) != null) {
                Log.i(TAG, line);
                String[] splited = line.split("\\s+");
                if (splited != null && splited.length > 5) {
                    if(!splited[3].equals("00:00:00:00:00:00")&&splited[5].contains(deviceName)){
                        String ip = splited[0];
                        connectedIP.add(ip);
                    }
                }
            }
            Log.i(TAG,"arp end");
        } catch (IOException e) {
            e.printStackTrace();
        }
//        connectedIP.remove(0);
        return connectedIP;
    }
 
Example #5
Source File: RepairnatorPostBuild.java    From repairnator with MIT License 5 votes vote down vote up
public void runRepairnator(EnvVars env) throws IOException,InterruptedException{
    Config config = this.config;
    System.out.println("jar location " + config.getJarLocation());
    RepairnatorProcessBuilder repProcBuilder = new RepairnatorProcessBuilder()
                                    .useJavaExec(config.getJavaExec())
                                    .atJarLocation(config.getJarLocation())
                                    .onGitUrl(config.getGitUrl())
                                    .onGitBranch(config.getGitBranch())
                                    .onGitOAuth(config.getGitOAuth())
                                    .withSmtpUsername(config.getSmtpUsername())
                                    .withSmtpPassword(config.getSmtpPassword())
                                    .withSmtpServer(config.getSmtpServer())
                                    .withSmtpPort(config.getSmtpPort())
                                    .shouldNotifyTo(config.getNotifyTo())
                                    .withRepairTools(config.getTools())
                                    .withSonarRules(config.getSonarRules())
                                    .useSmtpTls(config.useTLSOrSSL())
                                    .asNoTravisRepair()
                                    .alsoCreatePR()
                                    .withMavenHome(config.getMavenHome())
                                    .atWorkSpace(config.getTempDir().getAbsolutePath())
                                    .withOutputDir(config.getTempDir().getAbsolutePath());

    ProcessBuilder builder = repProcBuilder.build().directory(config.getTempDir());
    builder.redirectErrorStream(true);
    builder.inheritIO().redirectOutput(ProcessBuilder.Redirect.PIPE);
    Process process = builder.start();
    this.printProcessOutPut(process);
    process.waitFor();
}
 
Example #6
Source File: MXBeanWeirdParamTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Runs MXBeanWeirdParamTest$ClientSide with the passed options and redirects
 * subprocess standard I/O to the current (parent) process. This provides a
 * trace of what happens in the subprocess while it is runnning (and before
 * it terminates).
 *
 * @param serviceUrlStr string representing the JMX service Url to connect to.
 */
private int runClientSide(String serviceUrlStr) throws Exception {

    // Building command-line
    List<String> opts = buildCommandLine();
    opts.add(serviceUrlStr);

    // Launch separate JVM subprocess
    int exitCode = 0;
    String[] optsArray = opts.toArray(new String[0]);
    ProcessBuilder pb = new ProcessBuilder(optsArray);
    Process p = ProcessTools.startProcess("MXBeanWeirdParamTest$ClientSide", pb);

    // Handling end of subprocess
    try {
        exitCode = p.waitFor();
        if (exitCode != 0) {
            System.out.println(
                "Subprocess unexpected exit value of [" + exitCode +
                "]. Expected 0.\n");
        }
    } catch (InterruptedException e) {
        System.out.println("Parent process interrupted with exception : \n " + e + " :" );

        // Parent thread unknown state, killing subprocess.
        p.destroyForcibly();

        throw new RuntimeException(
            "Parent process interrupted with exception : \n " + e + " :" );
    } finally {
        return exitCode;
    }

 }
 
Example #7
Source File: derbyrunjartest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
private static void runtool(jvm jvm, String loc, String[] args)
    throws IOException
{
    System.out.println(concatenate(args) + ':');

    if (jvm == null) {
        com.pivotal.gemfirexd.internal.iapi.tools.run.main(args);
        return;
    }

    Vector cmd = jvm.getCommandLine();
    cmd.addElement("-jar");
    cmd.addElement(loc);
    for (int i=0; i < args.length; i++) {
        cmd.addElement(args[i]);
    }
    String command = concatenate((String[]) cmd.toArray(new String[0]));

    Process pr = null;

    try
    {
        pr = Runtime.getRuntime().exec(command);
        BackgroundStreamSaver saver = 
                    new BackgroundStreamSaver(pr.getInputStream(), System.out);
        saver.finish();
        pr.waitFor();
        pr.destroy();
    } catch(Throwable t) {
        System.out.println("Process exception: " + t.getMessage());
        if (pr != null)
        {
            pr.destroy();
            pr = null;
        }
    }
}
 
Example #8
Source File: MXBeanWeirdParamTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Runs MXBeanWeirdParamTest$ClientSide with the passed options and redirects
 * subprocess standard I/O to the current (parent) process. This provides a
 * trace of what happens in the subprocess while it is runnning (and before
 * it terminates).
 *
 * @param serviceUrlStr string representing the JMX service Url to connect to.
 */
private int runClientSide(String serviceUrlStr) throws Exception {

    // Building command-line
    List<String> opts = buildCommandLine();
    opts.add(serviceUrlStr);

    // Launch separate JVM subprocess
    int exitCode = 0;
    String[] optsArray = opts.toArray(new String[0]);
    ProcessBuilder pb = new ProcessBuilder(optsArray);
    Process p = ProcessTools.startProcess("MXBeanWeirdParamTest$ClientSide", pb);

    // Handling end of subprocess
    try {
        exitCode = p.waitFor();
        if (exitCode != 0) {
            System.out.println(
                "Subprocess unexpected exit value of [" + exitCode +
                "]. Expected 0.\n");
        }
    } catch (InterruptedException e) {
        System.out.println("Parent process interrupted with exception : \n " + e + " :" );

        // Parent thread unknown state, killing subprocess.
        p.destroyForcibly();

        throw new RuntimeException(
            "Parent process interrupted with exception : \n " + e + " :" );
    } finally {
        return exitCode;
    }

 }
 
Example #9
Source File: DaCapoClientRunner.java    From dacapobench with Apache License 2.0 5 votes vote down vote up
public static void runIteration(String size, int numThreads, boolean useBeans) {

    try {

      /* Calling the function directly does not launch the client now. According to testing, it seems the getMain method of boot does not work properlly.
         Thus these ugly codes are temporarily used for checking the whole framework
         Will be changed once the problem is fixed
      */
      //ClientCLI.main(new String[] { car, "-i", "-t", numThreads + "", "-s", size, useBeans ? "-b" : "" });

      String jhome= System.getProperty("java.home");

      ProcessBuilder pb = new ProcessBuilder(jhome + "/bin/java", "-jar", "-Dkaraf.startLocalConsole=false", gero + "/bin/client.jar", car, "-t", numThreads + "", "-s", size, useBeans ? "-b" : "");
      Process p = pb.start();
      p.waitFor();

      BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
      while (stdInput.ready()) { //While there's something in the buffer
        //read&print - replace with a buffered read (into an array) if the output doesn't contain CR/LF
        System.out.println(stdInput.readLine());
      }

    } catch (Exception e) {
      System.err.print("Exception running client iteration: " + e.toString());
      e.printStackTrace();
    }
  }
 
Example #10
Source File: HostInfo.java    From spring-rest with Apache License 2.0 5 votes vote down vote up
public static String execReadToString(String execCommand) throws IOException {
    Process proc = Runtime.getRuntime().exec(execCommand);
    try (InputStream stream = proc.getInputStream()) {
        try (Scanner s = new Scanner(stream).useDelimiter("\\A")) {
            return s.hasNext() ? s.next() : "";
        }
    }
}
 
Example #11
Source File: MXBeanWeirdParamTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Runs MXBeanWeirdParamTest$ClientSide with the passed options and redirects
 * subprocess standard I/O to the current (parent) process. This provides a
 * trace of what happens in the subprocess while it is runnning (and before
 * it terminates).
 *
 * @param serviceUrlStr string representing the JMX service Url to connect to.
 */
private int runClientSide(String serviceUrlStr) throws Exception {

    // Building command-line
    List<String> opts = buildCommandLine();
    opts.add(serviceUrlStr);

    // Launch separate JVM subprocess
    int exitCode = 0;
    String[] optsArray = opts.toArray(new String[0]);
    ProcessBuilder pb = new ProcessBuilder(optsArray);
    Process p = ProcessTools.startProcess("MXBeanWeirdParamTest$ClientSide", pb);

    // Handling end of subprocess
    try {
        exitCode = p.waitFor();
        if (exitCode != 0) {
            System.out.println(
                "Subprocess unexpected exit value of [" + exitCode +
                "]. Expected 0.\n");
        }
    } catch (InterruptedException e) {
        System.out.println("Parent process interrupted with exception : \n " + e + " :" );

        // Parent thread unknown state, killing subprocess.
        p.destroyForcibly();

        throw new RuntimeException(
            "Parent process interrupted with exception : \n " + e + " :" );
    } finally {
        return exitCode;
    }

 }
 
Example #12
Source File: MyTestUtils.java    From semanticvectors with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Utility for taking a main class, executing it as a process,
 * and returning a scanner of that process stdout.
 * Callers takes ownership of returned Scanner and should close() the scanner when done.
 */
public static Scanner getCommandOutput(Class<?> childMain, String[] args) {
  OutputScanner outputScanner = new OutputScanner();
  OutputStream outputStream = outputScanner.getOutputStream();
  Scanner scan = outputScanner.getScanner();
  scan.useDelimiter(System.getProperty("line.separator"));
  try {
    Process p = spawnChildProcess(childMain, args, null, outputStream, null);
    waitForAndDestroy(p);
  } catch (IOException e) { e.printStackTrace(); }
  return scan;
}
 
Example #13
Source File: MXBeanWeirdParamTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Runs MXBeanWeirdParamTest$ClientSide with the passed options and redirects
 * subprocess standard I/O to the current (parent) process. This provides a
 * trace of what happens in the subprocess while it is runnning (and before
 * it terminates).
 *
 * @param serviceUrlStr string representing the JMX service Url to connect to.
 */
private int runClientSide(String serviceUrlStr) throws Exception {

    // Building command-line
    List<String> opts = buildCommandLine();
    opts.add(serviceUrlStr);

    // Launch separate JVM subprocess
    int exitCode = 0;
    String[] optsArray = opts.toArray(new String[0]);
    ProcessBuilder pb = new ProcessBuilder(optsArray);
    Process p = ProcessTools.startProcess("MXBeanWeirdParamTest$ClientSide", pb);

    // Handling end of subprocess
    try {
        exitCode = p.waitFor();
        if (exitCode != 0) {
            System.out.println(
                "Subprocess unexpected exit value of [" + exitCode +
                "]. Expected 0.\n");
        }
    } catch (InterruptedException e) {
        System.out.println("Parent process interrupted with exception : \n " + e + " :" );

        // Parent thread unknown state, killing subprocess.
        p.destroyForcibly();

        throw new RuntimeException(
            "Parent process interrupted with exception : \n " + e + " :" );
    } finally {
        return exitCode;
    }

 }
 
Example #14
Source File: MyTestUtils.java    From semanticvectors with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Spawn a child to execute the main method in Class childMain
 * using the same args and environment as the current runtime.
 * This method prevents a child processes from hanging
 * when its output buffers saturate by creating threads to
 * empty the output buffers.
 * @return The process, already started. Consider using waitForAndDestroy() to clean up afterwards.
 * @param childMain The Class to spawn, must contain main function
 * @param inputArgs arguments for the main class. Use null to pass no arguments.
 * @param in The child process will read input from this stream. Use null to avoid reading input. Always close() your stream when you are done or you may deadlock.
 * @param out The child process will write output to this stream. Use null to avoid writing output.
 * @param err The child process will write errors to this stream. Use null to avoid writing output.
 */
public static Process spawnChildProcess(
    Class<?> childMain, String[] inputArgs, InputStream in, OutputStream out, OutputStream err)
    throws IOException {
  //get the same arguments as used to start this JRE
  RuntimeMXBean rmxb = ManagementFactory.getRuntimeMXBean();
  List<String> arglist = rmxb.getInputArguments();
  String cp = rmxb.getClassPath();

  //construct "java <arguments> <main-class-name>"
  ArrayList<String> arguments = new ArrayList<String>(arglist);
  arguments.add(0, "java");
  arguments.add("-classpath");
  arguments.add(cp);
  arguments.add(childMain.getCanonicalName());
  for (String arg : inputArgs) arguments.add(arg);

  //using ProcessBuilder initializes the child process with parent's env.
  ProcessBuilder pb = new ProcessBuilder(arguments);

  //redirecting STDERR to STDOUT needs to be done before starting
  if (err == out) {
    pb.redirectErrorStream(true);
  }

  Process proc;
  proc = pb.start(); //Might throw an IOException to calling method

  //setup stdin
  if (in != null) {
    new OutputReader(in, proc.getOutputStream()).start();
  }

  //setup stdout
  if (out == null) {
    out = new NullOutputStream();
  }
  new OutputReader(proc.getInputStream(), out).start();

  //setup stderr
  if (!pb.redirectErrorStream()) {
    if (err == null) {
      err = new NullOutputStream();
    }
    new OutputReader(proc.getErrorStream(), err).start();
  }

  return proc;
}
 
Example #15
Source File: MXBeanWeirdParamTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Runs MXBeanWeirdParamTest$ClientSide with the passed options and redirects
 * subprocess standard I/O to the current (parent) process. This provides a
 * trace of what happens in the subprocess while it is runnning (and before
 * it terminates).
 *
 * @param serviceUrlStr string representing the JMX service Url to connect to.
 */
private int runClientSide(String serviceUrlStr) throws Exception {

    // Building command-line
    List<String> opts = buildCommandLine();
    opts.add(serviceUrlStr);

    // Launch separate JVM subprocess
    int exitCode = 0;
    String[] optsArray = opts.toArray(new String[0]);
    ProcessBuilder pb = new ProcessBuilder(optsArray);
    Process p = ProcessTools.startProcess("MXBeanWeirdParamTest$ClientSide", pb);

    // Handling end of subprocess
    try {
        exitCode = p.waitFor();
        if (exitCode != 0) {
            System.out.println(
                "Subprocess unexpected exit value of [" + exitCode +
                "]. Expected 0.\n");
        }
    } catch (InterruptedException e) {
        System.out.println("Parent process interrupted with exception : \n " + e + " :" );

        // Parent thread unknown state, killing subprocess.
        p.destroyForcibly();

        throw new RuntimeException(
            "Parent process interrupted with exception : \n " + e + " :" );
    } finally {
        return exitCode;
    }

 }
 
Example #16
Source File: MXBeanWeirdParamTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Runs MXBeanWeirdParamTest$ClientSide with the passed options and redirects
 * subprocess standard I/O to the current (parent) process. This provides a
 * trace of what happens in the subprocess while it is runnning (and before
 * it terminates).
 *
 * @param serviceUrlStr string representing the JMX service Url to connect to.
 */
private int runClientSide(String serviceUrlStr) throws Exception {

    // Building command-line
    List<String> opts = buildCommandLine();
    opts.add(serviceUrlStr);

    // Launch separate JVM subprocess
    int exitCode = 0;
    String[] optsArray = opts.toArray(new String[0]);
    ProcessBuilder pb = new ProcessBuilder(optsArray);
    Process p = ProcessTools.startProcess("MXBeanWeirdParamTest$ClientSide", pb);

    // Handling end of subprocess
    try {
        exitCode = p.waitFor();
        if (exitCode != 0) {
            System.out.println(
                "Subprocess unexpected exit value of [" + exitCode +
                "]. Expected 0.\n");
        }
    } catch (InterruptedException e) {
        System.out.println("Parent process interrupted with exception : \n " + e + " :" );

        // Parent thread unknown state, killing subprocess.
        p.destroyForcibly();

        throw new RuntimeException(
            "Parent process interrupted with exception : \n " + e + " :" );
    } finally {
        return exitCode;
    }

 }
 
Example #17
Source File: MXBeanWeirdParamTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Runs MXBeanWeirdParamTest$ClientSide with the passed options and redirects
 * subprocess standard I/O to the current (parent) process. This provides a
 * trace of what happens in the subprocess while it is runnning (and before
 * it terminates).
 *
 * @param serviceUrlStr string representing the JMX service Url to connect to.
 */
private int runClientSide(String serviceUrlStr) throws Exception {

    // Building command-line
    List<String> opts = buildCommandLine();
    opts.add(serviceUrlStr);

    // Launch separate JVM subprocess
    int exitCode = 0;
    String[] optsArray = opts.toArray(new String[0]);
    ProcessBuilder pb = new ProcessBuilder(optsArray);
    Process p = ProcessTools.startProcess("MXBeanWeirdParamTest$ClientSide", pb);

    // Handling end of subprocess
    try {
        exitCode = p.waitFor();
        if (exitCode != 0) {
            System.out.println(
                "Subprocess unexpected exit value of [" + exitCode +
                "]. Expected 0.\n");
        }
    } catch (InterruptedException e) {
        System.out.println("Parent process interrupted with exception : \n " + e + " :" );

        // Parent thread unknown state, killing subprocess.
        p.destroyForcibly();

        throw new RuntimeException(
            "Parent process interrupted with exception : \n " + e + " :" );
    } finally {
        return exitCode;
    }

 }
 
Example #18
Source File: Activation.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
void shutdownFast() {
    Process p = child;
    if (p != null) {
        p.destroy();
    }
}
 
Example #19
Source File: Activation.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
void shutdownFast() {
    Process p = child;
    if (p != null) {
        p.destroy();
    }
}
 
Example #20
Source File: Activation.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
void shutdownFast() {
    Process p = child;
    if (p != null) {
        p.destroy();
    }
}
 
Example #21
Source File: Activation.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
void shutdownFast() {
    Process p = child;
    if (p != null) {
        p.destroy();
    }
}
 
Example #22
Source File: Activation.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
void shutdownFast() {
    Process p = child;
    if (p != null) {
        p.destroy();
    }
}
 
Example #23
Source File: JAudioFile.java    From jAudioGIT with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static void main(String[] args) throws Exception{
   	processor = new AudioStreamProcessor(args[0],args[1]);

String base_prefix =args[2];
base_prefix += args[4];

ProcessBuilder gstreamerBuilder = new ProcessBuilder("gst-launch-1.0", "-q", "filesrc", "location="+args[3], "!", "decodebin", "!", "audioconvert", "!", "audio/x-raw,format=F32LE", "!", "fdsink");
Process gstreamer =  gstreamerBuilder.start();
       DataInputStream input = new DataInputStream(gstreamer.getInputStream());
ByteBuffer buffer = ByteBuffer.allocateDirect(1000000000);
buffer.order(java.nio.ByteOrder.LITTLE_ENDIAN);
       byte[] b = new byte[1000000];
int read=0;
int total=0;
while((read = input.read(b))>-1){
	total += read;
	if(read > 0)
		buffer.put(b,0,read);
}
System.out.println();
buffer.flip();
FloatBuffer db = buffer.asFloatBuffer();

       double[] samples = new double[total / 8];
for(int i=0;i<samples.length;++i){
	samples[i] = (db.get()+db.get()) / 2.0;
}	
db = null;
       buffer = null;
double max=0.0;
double min=0.0;
boolean okay = false;
if(samples.length < 512){
	throw new Exception("File is too small to analyze - "+samples.length+" samples");
}
for(int i=0;i<samples.length;++i){
		if((samples[i] > 1.0) || (samples[i] < -1.0)){
		throw new Exception("Badly formatted data "+i+" "+samples[i]);
	}
	if((samples[i] > 0.7)){
		okay = true;
	}
}
if(!okay){
	throw new Exception("Data is artificially small - probable endianess problem");
}
processor.process(samples);

Date date = new Date();
       String attach = date.toString();
       attach = Pattern.compile("\\s").matcher(attach).replaceAll("_");
       base_prefix += Pattern.compile(":").matcher(attach).replaceAll("-");
       processor.output(base_prefix);
   }
 
Example #24
Source File: RepairnatorPostBuild.java    From repairnator with MIT License 4 votes vote down vote up
public void printProcessOutPut(Process process) throws IOException{
    try (BufferedReader reader = new BufferedReader(
        new InputStreamReader(process.getInputStream()))) {
        reader.lines().forEach(line -> System.out.println(line));
    }
}
 
Example #25
Source File: derbyrunjartest.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
private static void runtool(jvm jvm, String loc, String[] args)
    throws IOException
{
    System.out.println(concatenate(args) + ':');

    if (jvm == null) {
        com.pivotal.gemfirexd.internal.iapi.tools.run.main(args);
        return;
    }

    Vector cmd = jvm.getCommandLine();
    cmd.addElement("-jar");
    cmd.addElement(loc);
    for (int i=0; i < args.length; i++) {
        cmd.addElement(args[i]);
    }
    String command = concatenate((String[]) cmd.toArray(new String[0]));

    Process pr = null;

    try
    {
        pr = Runtime.getRuntime().exec(command);
        BackgroundStreamSaver saver = 
                    new BackgroundStreamSaver(pr.getInputStream(), System.out);
        saver.finish();
        pr.waitFor();
        pr.destroy();
    } catch(Throwable t) {
        System.out.println("Process exception: " + t.getMessage());
        if (pr != null)
        {
            pr.destroy();
            pr = null;
        }
    }
}
 
Example #26
Source File: Activation.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
void shutdownFast() {
    Process p = child;
    if (p != null) {
        p.destroy();
    }
}
 
Example #27
Source File: Activation.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
void shutdownFast() {
    Process p = child;
    if (p != null) {
        p.destroy();
    }
}
 
Example #28
Source File: Activation.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
void shutdownFast() {
    Process p = child;
    if (p != null) {
        p.destroy();
    }
}
 
Example #29
Source File: Activation.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
void shutdownFast() {
    Process p = child;
    if (p != null) {
        p.destroy();
    }
}
 
Example #30
Source File: Activation.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
void shutdownFast() {
    Process p = child;
    if (p != null) {
        p.destroy();
    }
}