简体   繁体   中英

Ubuntu Libgdx problem - No X11 DISPLAY variable was set

My problem is with X11 variable - when Im trying to launch gdx-setup.jar i get output:

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,

    at java.desktop/java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:166)
    at java.desktop/java.awt.Window.<init>(Window.java:553)
    at java.desktop/java.awt.Frame.<init>(Frame.java:428)
    at java.desktop/java.awt.Frame.<init>(Frame.java:393)
    at java.desktop/javax.swing.JFrame.<init>(JFrame.java:180)
    at com.badlogic.gdx.setup.GdxSetupUI.<init>(GdxSetupUI.java:101)
    at com.badlogic.gdx.setup.GdxSetup.main(GdxSetup.java:620)

Im running ubuntu on my local laptop (NO SSH).
System details

I've tried commands:

sudo apt-get update --fix-missing sudo apt-get update sudo apt-get clean sudo apt-get autoremove sudo dpkg reconfigure -a sudo apt install -f

It didnt help at all...

When Im running AWT from intellij I can see GUI normally and there's no exception.

Ive followed there instructions while installing libgdx: https://tutorialforlinux.com/2022/11/14/step-by-step-libgdx-ubuntu-22-04-installation-guide/2/

echo $DISPLAY output:0

Installed: xorg-x11

Double clicking on jar causes with no response... Ive marked jar as executable

You can specify one of many installed java versions when running from intellij. When running from the command line its just a single one.I think your default java probably -actually truly is- headless. Follow this guide here to change your default command line java. I mean the error is specifically that if fails the headless check. Follow here to switch the default cmd line java version.

https://computingforgeeks.com/how-to-set-default-java-version-on-ubuntu-debian/

Its not unusual to have headless because thats all server side stuff needs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM