Unable to open DISPLAY

Creating a bug report/issue

x I have searched the existing open and closed issues

Required Information

  • DietPi version |


  • Distro version | echo $G_DISTRO_NAME $G_RASPBIAN

bookworm 0

  • Kernel version | uname --all

Linux DietPi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux

  • Architecture | dpkg --print-architecture

  • SBC model | echo $G_HW_MODEL_NAME or (EG: RPi3)

RPi 3 Model B+ (aarch64)

  • Power supply used | (EG: 5V 1A RAVpower)
  • SD card used | (EG: SanDisk ultra)
    120 Go hard disk connected by USB

Additional Information (if applicable)

  • Can this issue be replicated on a fresh installation of DietPi?
    Yes I think

Steps to reproduce

  1. Standard Dietpi installation with LXDE, TigerVNC, ProFTPD, Firefox and JAVA (Liberica JDK)
  2. RPI display output hardware is either nothing (Tiger VNC Viewer on WIndows system), either HDMI occasionally connected to Marantz amplifier connected to Epson video projector with 1920 x 1080 (16/9) resolution
  3. I set hdmi_drive=2 in /boot/config.txt
  4. WIth dietpi-config/Display Options, I set the resolution = vc4-fks-v3d Open GL 1920 x 1080

Expected behaviour

Actual behaviour

When launching a simple JavaFX program, I get the error message “Unable to open DISPLAY”
I found a workaround by adding DISPLAY parameter when launching it :
a) sudo DISPLAY=:1 java HelloFX → my form is visible with Tiger VNC Viewer (but not on the Video Projector)
b) sudo DISPLAY=:0 java HelloFX → my form is visible only on the Video Projector

I think I have an issue with the DISPLAY parameter
Also, I cannot change the size of my form in my Java program (but the “maximize” command of LXDE works)

Please could you help

TigerVNC creates a virtual X session at display :1, while a locally started X session (e.g. running startx) is started at display :0. It hence makes totally sense that your Java program only shows up on one of them, depending on which display you choose.

You can however configure TigerVNC to use the local X session at display :0 instead. See shared desktop mode here: Remote Desktop Access Software Options - DietPi.com Docs
The service then waits for any X session to appear before connecting to it. So it can then make sense to enable desktop autostart/login, e.g. via dietpi-autostart.

The DISPLAY variable is automatically set (or should be) when you launch your Java program from within an X session, e.g. from a terminal emulator started from the desktop. It should then choose the X session it was started from. But when starting it from e.g. SSH, via service or boot script, this variable is naturally not set and hence the Java program cannot know which display you want it to show up. Hence you must then define the variable manually, reasonably.