GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||
GeezerVison is showing www.tutorialspoint.com — Java Process Class
Selected Reading
Java Process ClassIntroductionThe Java Process class provides methods for performing input from the process, performing output to the process, waiting for the process to complete, checking the exit status of the process, and destroying (killing) the process. Class DeclarationFollowing is the declaration for java.lang.Process class − public abstract class Process extends Object Class constructors
Class methods
Methods inheritedThis class inherits methods from the following classes −
Destroying a Process ExampleThe following example shows the usage of Process destroy() method. We've created a Process object for notepad executable. Then we've kept system to wait for 10 seconds and then using destroy() method, notepad process is killed and a message is printed. package com.tutorialspoint;
public class ProcessDemo {
public static void main(String[] args) {
try {
// create a new process
System.out.println("Creating Process...");
Process p = Runtime.getRuntime().exec("notepad.exe");
// wait 10 seconds
System.out.println("Waiting...");
Thread.sleep(10000);
// kill the process
p.destroy();
System.out.println("Process destroyed.");
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
OutputLet us compile and run the above program, this will produce the following result − Creating Process... Waiting... Process destroyed. Advertisements
| ||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |