PROCESS
EXAMPLE 2: TO OPEN AND CLOSE NOTEPAD APPLICATION
import java.io.IOException;
public class notepad {
public static void main(String[] args) throws
InterruptedException, IOException {
Runtime runTime = Runtime.getRuntime();
System.out.println("Opening
notepad");
Process process =
runTime.exec("notepad");
try {
Thread.sleep(2000);
process.destroy();
System.out.println("Closing
notepad");
}
catch
(Exception ex) {
System.out.println(ex);
}
}
}
OUTPUT: This will open notepad as a process and it closes it.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.