When compiling one GUI program,I confront such error:
**Exception in thread “main” java.awt.HeadlessException:
No X11 DISPLAY variable was set,
but this program performed an operation which requires it.
at java.desktop/java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:166)
at java.desktop/java.awt.Window.(Window.java:553)
at java.desktop/java.awt.Frame.(Frame.java:428)
at java.desktop/javax.swing.JFrame.(JFrame.java:224)
at ucb.gui2.TopLevel.(TopLevel.java:51)
at game2048.GUI.(GUI.java:24)
at game2048.Main.main(Main.java:40)
Process finished with exit code 1**
I use the files in wsl,it doesn’t work.However,when I directly use files in windows,it works.(Utunbu 24.04 and openjdk-22(WSL))
I’ve searched the past posts about this and tried acquiring answers from gpt,including downloading vcxsrv and changing the version of jdk.But it doesn’t work.
How can I fix the problem,please?
lonebeetle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.