Thursday, November 18, 2010

Set JVM default property with _JAVA_OPTIONS

export _JAVA_OPTIONS=-Djava.awt.headless=true

java |more
Picked up _JAVA_OPTIONS: -Djava.awt.headless=true


Setting JVM -Djava.awt.headless=true is necessary if X server is not available.
Without this property following error is thrown:

Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using '' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.access$100(X11GraphicsEnvironment.java:52)
at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:155)
at java.security.AccessController.doPrivileged(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:131)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68)
at sun.font.FontManager.initSGEnv(FontManager.java:1307)
at sun.font.FontManager.findFont2D(FontManager.java:1984)
at java.awt.Font.getFont2D(Font.java:455)
at java.awt.Font.canDisplay(Font.java:1904)
at java.awt.Font.canDisplayUpTo(Font.java:1970)
at java.awt.font.TextLayout.singleFont(TextLayout.java:451)
at java.awt.font.TextLayout.<init>(TextLayout.java:509)
at org.apache.poi.hssf.usermodel.HSSFSheet.autoSizeColumn(HSSFSheet.java:1675)

No comments:

Post a Comment