Search processing.org:

Reference for Processing (BETA) version 0135+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.

Name

### open()

Examples

    void setup() {
      size(200, 200);
    }

    void draw() {
      // draw() must be present for mousePressed() to work
    }

    void mousePressed() {
      println("Opening Process_4");
      open("Process_4.exe");
    }

    void setup() {
      size(200, 200);
    }

    void draw() {
      // draw() must be present for mousePressed() to work
    }

    void mousePressed() {
      String[] params = { "jikes", "-help" };
      open(params);
    }

Description

Attempts to open an application or file using your platform's launcher. The file parameter is a String specifying the file name and location. When running sketches from the Processing environment the default location is the same folder as the Processing application itself.
It's also possible (and safer) to use a file's absolute path. Be sure to make the file executable before attempting to open it (chmod +x).
The args parameter is a String or String array which is passed to the command line. If you have multiple parameters, e.g. an application and a document, or a command with multiple switches, use the version that takes a String array, and place each individual item in a separate element.
If args is a String (not an array), then it can only be a single file or application with no parameters. It's not the same as executing that String using a shell. For instance, open("jikes -help") will not work properly.
This function behaves differently on each platform. On Windows, the parameters are sent to the Windows shell via "cmd /c". On Mac OS X, the "open" command is used (type "man open" in Terminal.app for documentation). On Linux, it first tries gnome-open, then kde-open, but if neither are available, it sends the command to the shell without any alterations. For Java users, this is not quite the same as Runtime.exec(), because the launcher command is prepended. The method exec(String[]) is a shortcut for Runtime.getRuntime.exec(String[]). In release 0125, this function was modified for Mac OS X and Linux support, and to better handle spaces in command names.

Syntax

    open(file)
    open(args)

Parameters

filename | String: name of the file
args | String[]: list of commands passed to the command line

Usage | Application

Updated on February 09, 2008 04:38:52pm PST