I’ve just learned some handy tricks about packaging Processing-based applications with OpenGL for deployment on Mac OS X. As it turns out, it’s remarkably easy to do on a PC if you use Processing’s own application export as a template. My thanks to Ben Fry for the tip (and also for all the other hard work he’s put into Processing…)

Create a sketch called “Dummy” in the Processing GUI. If your final application will use OpenGL, make sure that “Dummy” does as well. Export using “Export as application”. This produces several folders, of which only “application.macosx” is of interest. This has a “Dummy.app” subfolder which is the actual MacOS application. It’s not a single file, but rather a folder structure that on a Mac shows up as a clickable application. Change the name of “Dummy.app” to whatever name you want, keeping the magic “.app” extension.

In “Contents” you will find a file called “Info.plist”. This contains various parameters controlling your Java application, bundled as pairs of <key> and <string>. Make sure that “MainClass” string is the full name of your main class (including package name if any). Change all instances of “Dummy” to the name of your application. You can also tweak a bunch of other options at will.

If you have JAR files that you need to add, place them in the subfolder “Contents\Resources\Java”. It should already contain core.jar as well as the OpenGL-related JARs and jnilib libraries if you exported Dummy with OpenGL imported. You will need to include the new JARs in the “ClassPath” string found in “Info.plist”.

If all changes have been done correctly, you should now have a runnable application. Copy it to a Mac for testing.

For some icing on the cake (and as an alternative to present mode), you can hide the dock and menu bar on application start. Add the following lines to the <dict> section of “Info.plist”:

LSUIPresentationMode
4

Thanks to Vitaflo for his post on the Processing Forums for this tip.

If you compile your code including the Processing source in an IDE like Eclipse, you can simply replace core.jar with your own as long as it contains all the usual Processing class files. I’ve made a few small changes to the PApplet class, so I prefer this option to the standard JAR file.

This is particularly pertinent if you want your OpenGL apps to be anti-aliased on Mac OS, since smooth() does not always turn it on. The solution is to make an alteration to PGraphicsOpenGL using the GLCapabilities class. Read Mike Creighton's post on the Processing forums for the details.

There is one comment to "Deploying Java and Processing applications on Mac OS X". You may leave your own comment.
1. abstractmachine » !shadows, May 23rd, 2007 at 17:43

[...] Thanks to Marius Watz and VitaFlo I’ve been able to make a nice Mac OS X full screen application that can open other windows on top of it. Usually Processing runs full-screen applications Java-style, i.e. on top of all other windows, including the dock & menu. But since I want my Applet to be a launching-pad for several websites, videos, and applications, I needed a different solution. Marius’ proposition only removes the menu & dock; this allows for many different solutions for what I want, several of which I’m exploring this week. [...]

Comment on this entry

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>