Linux, java.awt.headless and the DISPLAY environment variable
Just a quick note to self:
After looking at the JDK source code today, we found that even when setting -Djava.awt.headless=true, if a script executes with the DISPLAY environment variable set, the AWT graphics environment will still use a GraphicsEnvironment representing that DISPLAY.
A major problem with this is if the shell that launched the script that started the java process ever executes, the GraphicsEnvironment reflecting the DISPLAY will be removed and any Object instances reflecting that environment would be invalidated or Classes once available will no longer be available. resulting in a NoClassDefFoundException.
Bottom line: on Linux, if setting -Djava.awt.headless=true in a script, ensure that you unset DISPLAY in the script before starting the java process. It will save some headaches in debugging.
Tags
Archives
- June 2011
- December 2010
- November 2010
- September 2010
- April 2010
- February 2010
- January 2010
- December 2009
- November 2009
- August 2009
- May 2009
- March 2009
- December 2008
- August 2008
- March 2008
- February 2008
- January 2008
- December 2007
- August 2007
- July 2007
- June 2007
- February 2007
- November 2006
- August 2006
- July 2006
- June 2006
- April 2006
- March 2006
- February 2006
- January 2006




