Exception in thread "AWT-EventQueue-0" java.awt.HeadlessException

edited May 2017 in Raspberry PI

I get this error when trying to run Processing 3.3.3 ARM64 version on Raspberry Pi under OpenSUSE Tumbleweed LxQT.

I turned on logging in the processing script; here is the full output:

david@raspberrypi:~/processing> ./processing
APPDIR=/home/david/processing
DIR=/home/david/processing/java
L=rt.jar
LIB=/home/david/processing/java/lib/rt.jar
JDKCP=/home/david/processing/java/lib/rt.jar
SUCCESS=1
CLASSPATH=/home/david/processing/java/lib/rt.jar:/home/david/processing/lib/ant.jar:/home/david/processing/lib/ant-launcher.jar:/home/david/processing/lib/jna.jar:/home/david/processing/lib/jna-platform.jar:/home/david/processing/lib/pde.jar:/home/david/processing/core/library/core.jar:/home/david/processing/core/library/gluegen-rt.jar:/home/david/processing/core/library/gluegen-rt-natives-linux-aarch64.jar:/home/david/processing/core/library/gluegen-rt-natives-linux-amd64.jar:/home/david/processing/core/library/gluegen-rt-natives-linux-armv6hf.jar:/home/david/processing/core/library/gluegen-rt-natives-linux-i586.jar:/home/david/processing/core/library/gluegen-rt-natives-macosx-universal.jar:/home/david/processing/core/library/gluegen-rt-natives-windows-amd64.jar:/home/david/processing/core/library/gluegen-rt-natives-windows-i586.jar:/home/david/processing/core/library/jogl-all.jar:/home/david/processing/core/library/jogl-all-natives-linux-aarch64.jar:/home/david/processing/core/library/jogl-all-natives-linux-amd64.jar:/home/david/processing/core/library/jogl-all-natives-linux-armv6hf.jar:/home/david/processing/core/library/jogl-all-natives-linux-i586.jar:/home/david/processing/core/library/jogl-all-natives-macosx-universal.jar:/home/david/processing/core/library/jogl-all-natives-windows-amd64.jar:/home/david/processing/core/library/jogl-all-natives-windows-i586.jar:/home/david/processing/modes/java/mode/antlr.jar:/home/david/processing/modes/java/mode/classpath-explorer-1.0.jar:/home/david/processing/modes/java/mode/com.ibm.icu.jar:/home/david/processing/modes/java/mode/JavaMode.jar:/home/david/processing/modes/java/mode/jdi.jar:/home/david/processing/modes/java/mode/jdimodel.jar:/home/david/processing/modes/java/mode/jdtCompilerAdapter.jar:/home/david/processing/modes/java/mode/jsoup-1.7.1.jar:/home/david/processing/modes/java/mode/org.eclipse.core.contenttype.jar:/home/david/processing/modes/java/mode/org.eclipse.core.jobs.jar:/home/david/processing/modes/java/mode/org.eclipse.core.resources.jar:/home/david/processing/modes/java/mode/org.eclipse.core.runtime.jar:/home/david/processing/modes/java/mode/org.eclipse.equinox.common.jar:/home/david/processing/modes/java/mode/org.eclipse.equinox.preferences.jar:/home/david/processing/modes/java/mode/org.eclipse.jdt.core.jar:/home/david/processing/modes/java/mode/org.eclipse.osgi.jar:/home/david/processing/modes/java/mode/org.eclipse.text.jar:/home/david/processing/modes/java/mode/org.netbeans.swing.outline.jar
PATH=/home/david/processing/java/bin:/home/david/.yarn/bin:/home/david/.yarn/bin:/home/david/bin:/usr/local/bin:/usr/bin:/bin
david@raspberrypi:~/processing> Exception in thread "AWT-EventQueue-0" java.awt.HeadlessException
    at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
    at java.awt.Window.<init>(Window.java:536)
    at java.awt.Frame.<init>(Frame.java:420)
    at java.awt.Frame.<init>(Frame.java:385)
    at processing.app.Messages.showTrace(Messages.java:177)
    at processing.app.Base$1.run(Base.java:119)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

Answers

  • Further info: it appears not to be a Processing thing; I get the same error when I run any Java program that wants to do graphics.

  • java.awt.HeadlessException

    it thinks you aren't running a desktop on your pi

    what does echo $DISPLAY say?

  • It says :0.0 OpenJDK works fine; it's an Oracle thing, apparently.

  • edited May 2017

    After looking at the source and doing some testing, the problem is that the version of Java that I am using (downloaded from jdk-8u131-linux-arm64-vfp-hflt.tar.gz) has java.awt.headless set to true Setting the flag to false on the command line doesn’t help; you then get an error that libawt_xawt.so can’t be loaded. [Later edit:] It would appear that graphics aren’t a part of that particular distribution at all.

  • edited June 2017

    @jdheisenberg Interesting. Do you have a link to an image file that I could try to run on my Raspberry Pi 3?

    And this Tumbleweed is running X, not some Wayland server? You're getting this output when you run it inside an X session?

    Just out of curiosity: you could also try executing a sketch from the terminal and see how far you get there. It should be something like ./processing-java --sketch=/home/david/processing/modes/java/examples/Basics/Transform/Rotate --run.

  • edited June 2017

    Your example gives an ExceptionInInitializerError

    Consider the following code, which I modified from java.awt.GraphicsEnvironment:

    class Testor {
    
        private static Boolean headless;
        private static Boolean defaultHeadless;
    
        private static boolean getHeadlessProperty() {
            System.out.println("Upon entry, headless is: " + headless);
            if (headless == null) {
                    String nm = System.getProperty("java.awt.headless");
                    System.out.println("java.awt.headless is: " + nm);
                    if (nm == null) {
                        /* No need to ask for DISPLAY when run in a browser */
                        if (System.getProperty("javaplugin.version") != null) {
                            headless = defaultHeadless = Boolean.FALSE;
                        } else {
                            String osName = System.getProperty("os.name");
                            System.out.println("osName is: |" + osName + "|");
                            if (osName.contains("OS X") && "sun.awt.HToolkit".equals(
                                    System.getProperty("awt.toolkit")))
                            {
                                headless = defaultHeadless = Boolean.TRUE;
                            } else {
                                final String display = System.getenv("DISPLAY");
                                System.out.println("display is: " + display);
                                System.out.println("defaultHeadless is: " + defaultHeadless);
                                headless = defaultHeadless =
                                    ("Linux".equals(osName) ||
                                     "SunOS".equals(osName) ||
                                     "FreeBSD".equals(osName) ||
                                     "NetBSD".equals(osName) ||
                                     "OpenBSD".equals(osName) ||
                                     "AIX".equals(osName)) &&
                                     (display == null || display.trim().isEmpty());
                            }
                        }
                    } else {
                        headless = Boolean.valueOf(nm);
                    }
            }
            System.out.println("About to return result: " + headless);
            return headless;
        }
    
      public static void main(String [] args) {
        System.out.println(getHeadlessProperty());
      }
    
    }
    

    Here is what happens when I run it from OpenJDK and from the java that comes with Processing. A result of false means that there is a graphic display; a result of true means there is no graphic display.

    david@raspberrypi:~/testor> java -version
    openjdk version "1.8.0_121"
    OpenJDK Runtime Environment (IcedTea 3.3.0) (suse-3.7-aarch64)
    OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)
    david@raspberrypi:~/testor> java Testor
    Upon entry, headless is: null
    java.awt.headless is: null
    osName is: |Linux|
    display is: :0.0
    defaultHeadless is: null
    About to return result: false
    false
    
    david@raspberrypi:~/testor> ~/processing-3.3.3/java/bin/java -version
    java version "1.8.0_131"
    Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
    Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
    david@raspberrypi:~/testor> ~/processing-3.3.3/java/bin/java Testor
    Upon entry, headless is: null
    java.awt.headless is: true
    About to return result: true
    true
    
  • @jdeisenberg Thanks for confirming this. Were you able to test Processing with the OpenJDK VM? (Replacing the java directory with a symlink should work)

  • Yes, it works great (of course, it gives the warning about not using OpenJDK).

Sign In or Register to comment.