Java console error could not initialize class sun.awt.X11GraphicsEnvironment
Well this is another sanity post to save me next time I need to figure this problem out again, the issue is running a applet on a server in a Headless X11 environment.
There are java program settings to force checking that a X11 display is present and similar command line options to do the same, thowever this doesn't help when trying to run on your server console terminal in a Headless environment.
What the solution, you need to install on your Linux box the Xvfb package and set the appropriate DISPLAY shell variable in your console terminal.
Without a X11 screen you'll get an error similar to the following :-
Show Plain Text- Exception in thread "main" java.awt.HeadlessException:
- No X11 DISPLAY variable was set, but this program performed an operation which requires it.
- at sun.awt.HeadlessToolkit.getScreenSize(HeadlessToolkit.java:261)
- ...
To solve this issue you need to start the Xvfb virtual frame buffer software and set in your console terminal the corresponding display number to use, for example :-
Show Plain Text- Xvfb :2&
- export DISPLAY=":2"
Then run your application and bobs your uncle...