8.6. Execution of Non-Java Programs

Because of default security restrictions, applets (Java programs embedded in Web pages) cannot execute system programs; however, applications (stand-alone Java programs) can execute system programs. Starting a local program involves the following four steps:

1.
Get the special Runtime object. Use the static getRuntime method of the Runtime class for this, as follows:
Runtime rt = Runtime.getRuntime();
2.
Execute the program. Use the exec method, which returns a Process object, as illustrated below:
Process proc = rt.exec("someProgram");
This starts the program but does not wait for the program to terminate or print the program results. Note that the exec method does not make use of your PATH environment ...

Get Core Web Programming, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.