Process Processbuilder : Processes Programs or Applications. Processes
Process Processbuilder : Processes Programs or Applications. Processes
1
Roberto Tantalean 2013
53
Process
It has a self-contained execution environment
(private set of basic run-time resources, each process has
its own memory space).
Processes ~ programs or applications.
A single application may in fact be a set of cooperating
processes.
To facilitate communication between processes, most
operating systems support Inter Process
Communication (IPC) resources, such as pipes and
sockets (Even processes on different systems).
A Java application can create additional processes using
a ProcessBuilder object.
Roberto Tantalean 2013
54
ProcessBuilder()
This class is used to create operating system processes.
Each ProcessBuilder instance manages a collection of
process attributes.
The start() method creates a new Process instance with
those attributes.
The start() method can be invoked repeatedly from the
same instance to create new subprocesses with identical
or related attributes.
Roberto Tantalean 2013
55
Starting a new process which uses the default working
directory and environment is:
Process p = new ProcessBuilder("myCommand",
"myArg1,
myArg2, ...).start();
Roberto Tantalean 2013
56
Example:
//Archivo: Process1.java
// Executes the application TanqueNivelOnline.exe
import java.io.*;
class Process1 {
public static void main(String[] args)
throws IOException{
ProcessBuilder pb = new
ProcessBuilder("TanqueNivelOnline.exe");
Process p = pb.start(); }
}