-
-
Notifications
You must be signed in to change notification settings - Fork 6
Exporting Applications
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.
-
Warning: Whenever you export, it will replace your old application folders completely. This means that the
macos-aarch64
orlinux-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 thelib
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 andlib/args.txt
on Windows and Linux).
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 toPApplet
. Use the following code to prevent ESC from quitting the application:void keyPressed() { if (key == ESC) { key = 0; // Fools! don't let them escape! } }
Applications on macOS must be signed and notarized or they will be reported as damaged or unsafe.
During the Export to Application process, Processing will attempt to self-sign your app, which at least makes it possible for you to run the application, period. In order to self-sign, you must first have the Xcode command line tools installed. You'll be prompted to do this in the Export dialog box, or you can do it from the Terminal by typing xcode-select --install
.
If you package your app and share it with someone else, they may see a message like:
“FriederNake.app” can't be opened because Apple cannot check it for malicious software
This means that the application is not fully signed and notarized. To fix, there are three options:
-
Right-click and select “Open” from the pop-up menu. This will give you a slightly different dialog box, which will allow you to still Open the app.
-
Open a Terminal window and type:
xattr -d com.apple.quarantine /path/to/FriederNake.app
or if that still does not work, try:
xattr -cr /path/to/FriederNake.app
Tip: you can get the full path to your app (the
/path/to/FriederNake.app
part above) by dragging the.app
file into the Terminal window. So typexattr -cr
, then drag the app into the window, then hit return. Done! -
Get an Apple Developer account so that you can sign and notarize your software.
This costs $99/year, and also means learning about Gatekeeper and Developer IDs. Some helpful resources to get your started:
-
Also check out the official documentation for Gatekeeper and Developer IDs
-
An application for macOS can only be exported from macOS. This is due to the complexity of how Java works on macOS, and Apple's requirements for code signing and notarization.
-
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 fromProcessing.app/Contents/Java/modes/java/application/Info.plist.tmpl
). Any changes made to that copy ofInfo.plist.tmpl
will be used whenever that sketch is exported.
-
Use this code to set the icon used in the title bar:
PImage icon = loadImage("myicon.png"); surface.setIcon(icon);
- The Linux application is just a shell script, which can probably be used on most Unix platforms.