Sample Header Ad - 728x90

"No X11 DISPLAY variable was set [...]" when using java.swing

1 vote
2 answers
3811 views
When I'm trying to run a Java GUI application from the command line, I get:
Exception in thread "main" java.awt.HeadlessException:
"No X11 DISPLAY variable was set,
or no headful library support was found,
but this program performed an operation which requires it,"
I keep getting this error whenever I try to run code with java.swing GUI components. $DISPLAY is set to :0 and java --version gives me openjdk 19.0.1. edit: I tried to run java Main with either wayland or xorg but I get the same error.
Asked by CocoaPowder (11 rep)
Jan 25, 2023, 10:11 AM
Last activity: Apr 23, 2025, 03:06 AM