Skip to content

Exporting Applications

Ben Fry edited this page Aug 6, 2022 · 6 revisions

Processing can export Java Applications for Linux, macOS, and Windows. Select “Export Application” from the “File” menu, which will open a dialog box with a few options. After clicking Export, a folder will be created for your application, the source code, and all required libraries will be embedded as well.

Some hints and notes follow below. If you find problems, file a bug.

  • Warning: Whenever you export, it will replace your old application folders completely. This means that the macos-aarch64 or linux-amd64 folders will be deleted and rewritten.

  • It's possible to embed Java with exported applications. The positive side of this is that it makes the application much more likely to behave exactly as it does when run from the PDE, and that users of the exported application won't have to install anything additional. The downside is that exported applications are much larger. We strongly recommended that you embed Java with your application. Not including it opens a pandora's box of problems that can happen when people try to run your project.

  • It is important that you don't have a method named main() in your sketch, unless you really know what you're doing.

  • Use the windowTitle() method to change the name of the application window.

  • When distributing your application, the source folder can be removed from the export if you'd like, but other files (such as the lib folder) should be left intact, otherwise the application will not work.

  • Your current memory settings will be exported with the application. If you've set outrageous memory requirements, you might want to undo that before exporting for others, or edit the exported files by hand (Contents/Resources/Info.plist on macOS and lib/args.txt on Windows and Linux).

Presentation Mode

The Presentation Mode simply clears the rest of the screen when running the sketch. You can set the default background color (for the area around your sketch) in the Export to Application window.

  • Pressing the ESC key will quit a sketch, even in Present mode. To prevent this from happening, intercept the ESC on keyPressed() so that it isn't passed through to PApplet. Use the following code to prevent ESC from quitting the application:

    void keyPressed() {
      if (key == ESC) {
        key = 0;  // Fools! don't let them escape!
      }
    }

macOS

  • An application for macOS can only be exported from macOS. This is due to the complexity of how Java works on macOS, and the limitations of the appbundler library that we use.

  • You can also customize the exported application automatically by copying the Info.plist.tmpl file from inside the Processing.app package into your sketch (copy it from Processing.app/Contents/Java/modes/java/application/Info.plist.tmpl). Any changes made to that copy of Info.plist.tmpl will be used whenever that sketch is exported.

Windows

  • Use this code to set the icon used in the title bar:
PImage titlebaricon = loadImage("myicon.png");
surface.setIcon(titlebaricon);

Linux

  • The Linux application is just a shell script, which can probably be used on most Unix platforms (there's almost nothing to it).
Clone this wiki locally