From ba7a213ed3023e1b9a90d8c9efc4423e2277795e Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Mon, 15 Jun 2015 08:13:10 -0400 Subject: [PATCH] catch headless exceptions and send to Github --- core/src/processing/core/PApplet.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index d17d8fb79..1b6bbf917 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -34,12 +34,14 @@ import java.awt.Font; import java.awt.Frame; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; +import java.awt.HeadlessException; import java.awt.Image; import java.awt.Toolkit; import java.awt.color.ColorSpace; import java.awt.image.BufferedImage; + // used by loadImage() functions import javax.imageio.ImageIO; import javax.swing.ImageIcon; @@ -823,6 +825,8 @@ public class PApplet implements PConstants { boolean fullScreen; int display = -1; // use default GraphicsDevice[] displayDevices; + // Unlike the others above, needs to be public to support + // the pixelWidth and pixelHeight fields. public int pixelDensity = 1; String outputPath; @@ -9766,7 +9770,12 @@ public class PApplet implements PConstants { * */ static public void main(final String[] args) { - runSketch(args, null); + try { + runSketch(args, null); + } catch (HeadlessException e) { + System.err.println("Cannot run sketch without a display. Read this for possible solutions:"); + System.err.println("https://github.com/processing/processing/wiki/Running-without-a-Display"); + } }