OpenPOWER Library

 1.5.5. Java AWT exception

Use of Maven in headless environments from Mac OS has uncovered an intermittent exception in the AWT libraries. This error looks like the following:

Exception in thread "main" java.awt.AWTError: Can't connect to X11 window server using 'localhost:11.0' as the value of the DISPLAY variable.
	at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
	at sun.awt.X11GraphicsEnvironment.access$200(
	at sun.awt.X11GraphicsEnvironment$
	at Method)
	at sun.awt.X11GraphicsEnvironment.<clinit>(
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(
	at java.awt.GraphicsEnvironment.createGE(
	at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(
	at sun.awt.X11.XToolkit.<clinit>(

The circumvention for this error, is force AWT to run headless. This can be accomplished by adding the -Djava.awt.headless=true parameter to the maven invocation such that it looks like this:

$ mvn clean generate-sources -Djava.awt.headless=true

loading table of contents...