Java Swing X11 execution error

Hello,

Requirements:

I need some help sorting out a display server problem I’m having while trying to compile and run some java tutorial project files I’m working on. I can get my java main.java file to compile without issue, but it won’t run at all and kicks out a display server error.

I did a google search for headless errors and found this answer:

Since it’s a headless problem I followed the steps to make sure I had a full JDK installed. DNF said there was nothing to do, full development packages were already installed.

I dont’ have enough experience with the display server stuff to know what I’m looking at when reading the rest of the stuff.

I also did a search here on the forum for “headless” figuring that would be specific enough to go straight to relevant posts. Didn’t get anthing, so time for a post of my own.

OpenMandriva Lx version:

OpenMandriva Lx release 6.0 (Vanadium) Rock for x86_64

fastfetch
tanker3278@
OS: OpenMandriva Lx 6.0 (Vanadium) Rock x86_64
Host: 82R8 (IdeaPad Flex 5 16IAU7)
Kernel: Linux 6.14.2-desktop-3omv2590
ptime: 1 hour, 54 mins
Packages: 2825 (rpm)
Shell: bash 5.2.37
Display (BOE0A31): 1920x1200 @ 60 Hz in 16" [Built-in]
Display (Q2963): 2560x1080 @ 60 Hz in 29" [External]
DE: KDE Plasma 6.3.4
WM: KWin (X11)
WM Theme: Breeze
Theme: Breeze (Light) [Qt], Breeze [GTK2/3]
Icons: breeze [Qt], breeze [GTK2/3/4]
Font: Noto Sans (10pt) [Qt], Noto Sans (10pt) [GTK2/3/4]
Cursor: Breeze_Light (24px)
Terminal: konsole 25.4.0
Terminal Font: Liberation Mono (11pt)
CPU: 12th Gen Intel(R) Core™ i7-1255U (12) @ 4.70 GHz
GPU: Intel Iris Xe Graphics @ 1.25 GHz [Integrated]
Memory: 2.64 GiB / 7.34 GiB (36%)
Swap: 0 B / 4.17 GiB (0%)
Disk (/): 81.18 GiB / 468.09 GiB (17%) - ext4
Local IP
Battery (L21M3PE1): 94% [AC Connected]
Locale: en_US.UTF-8

Desktop environment (KDE, LXQT…):

env | grep -E -i ‘x11|xorg|wayland’
DESKTOP_SESSION=plasmax11
XDG_SESSION_TYPE=x11
QT_WAYLAND_RECONNECT=1

However, when I run echo $XDG_SESSION_TYPE on the command line I get a blank / no answer.

Description of the issue (screenshots if relevant):

Got Java install properly with some help. Was going to go back through my java Swing tutorial projects to make sure everything is still working since coming over from Fedora43. Had to sit on it a while after getting java straightened out but had some time tonight to give it a shot. Here’s what I ran into.

java main
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:164)
at java.desktop/java.awt.Window.(Window.java:553)
at java.desktop/java.awt.Frame.(Frame.java:428)
at java.desktop/java.awt.Frame.(Frame.java:393)
at java.desktop/javax.swing.JFrame.(JFrame.java:180)
at main.main(main.java:9)

Here’s the java code I was able to get compiled without error.

import javax.swing.JFrame;
public class main{
public static void main(String args) {
// JFrame = a GUI window to add components to
JFrame myframe = new JFrame(); // creates an instance of a frame.
myframe.setTitle(“JFrame title goes here”);
myframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myframe.setResizable(false);
myframe.setSize(420,420); // set X & Y dimension of our frame.
myframe.setVisible(true); // make frame visible.
}
}

Relevant informations (hardware involved, software version, logs or output…):

inxi -Fz
System:
Kernel: 6.14.2-desktop-3omv2590 arch: x86_64 bits: 64
Desktop: KDE Plasma v: 6.3.4 Distro: OpenMandriva Lx 6.0 Vanadium
Machine:
Type: Convertible System: LENOVO product: 82R8 v: IdeaPad Flex 5 16IAU7
serial:
Mobo: LENOVO model: LNVNB161216 v: SDK0T76463 WIN
serial: UEFI: LENOVO v: J7CN51WW date: 10/04/2024
Battery:
ID-1: BAT0 charge: 49.1 Wh (94.4%) condition: 52.0/52.5 Wh (99.0%)
CPU:
Info: 10-core (2-mt/8-st) model: 12th Gen Intel Core i7-1255U bits: 64
type: MST AMCP cache: L2: 6.5 MiB
Speed (MHz): avg: 600 min/max: 400/4700:3500 cores: 1: 600 2: 600 3: 600
4: 600 5: 600 6: 600 7: 600 8: 600 9: 600 10: 600 11: 600 12: 600
Graphics:
Device-1: Intel Alder Lake-UP3 GT2 [Iris Xe Graphics] driver: i915 v: kernel
Device-2: Chicony Integrated Camera driver: uvcvideo type: USB
Display: x11 server: X.org v: 1.21.1.18 driver: X: loaded: modesetting
unloaded: fbdev,vesa dri: iris gpu: i915 resolution: 1: 2560x1080~60Hz
2: 1920x1200~60Hz
API: EGL v: 1.5 drivers: iris,swrast platforms: gbm,x11,surfaceless,device
API: OpenGL v: 4.6 compat-v: 4.5 vendor: intel mesa v: 25.0.7
renderer: Mesa Intel Iris Xe Graphics (ADL GT2)
API: Vulkan v: 1.4.312 drivers: N/A surfaces: xcb,xlib
Info: Tools: api: clinfo, eglinfo, glxinfo, vulkaninfo de: kscreen-console
x11: xdpyinfo, xprop, xrandr
Audio:
Device-1: Intel Alder Lake PCH-P High Definition Audio
driver: sof-audio-pci-intel-tgl
API: ALSA v: k6.14.2-desktop-3omv2590 status: kernel-api
Server-1: PipeWire v: 1.4.4 status: active
Network:
Device-1: Realtek RTL8852BE PCIe 802.11ax Wireless Network
driver: rtw89_8852be
IF: wlp45s0 state: down mac:
Device-2: Realtek RTL8153 Gigabit Ethernet Adapter driver: r8152 type: USB
IF: enp0s13f0u1u4 state: up speed: 1000 Mbps duplex: full mac:
Bluetooth:
Device-1: Realtek Bluetooth Radio driver: btusb type: USB
Report: hciconfig ID: hci0 rfk-id: 2 state: down
bt-service: enabled,running rfk-block: hardware: no software: yes
address:
Drives:
Local Storage: total: 476.94 GiB used: 81.18 GiB (17.0%)
ID-1: /dev/nvme0n1 vendor: Samsung model: MZAL4512HBLU-00BL2
size: 476.94 GiB
Partition:
ID-1: / size: 468.09 GiB used: 81.17 GiB (17.3%) fs: ext4
dev: /dev/nvme0n1p2
ID-2: /boot/efi size: 299.4 MiB used: 9.2 MiB (3.1%) fs: vfat
dev: /dev/nvme0n1p1
Swap:
ID-1: swap-1 type: file size: 512 MiB used: 0 KiB (0.0%) file: /swapfile
ID-2: swap-2 type: zram size: 3.67 GiB used: 0 KiB (0.0%) dev: /dev/zram0
Sensors:
System Temperatures: cpu: 39.0 C mobo: N/A
Fan Speeds (rpm): N/A
Info:
Memory: total: 8 GiB note: est. available: 7.34 GiB used: 2.61 GiB (35.5%)
Processes: 272 Uptime: 1h 25m Shell: Bash inxi: 3.3.37

Please format these sections with Markdown so they can be read better. Like so:

fastfetch
tanker3278@
OS: OpenMandriva Lx 6.0 (Vanadium) Rock x86_64
Host: 82R8 (IdeaPad Flex 5 16IAU7)
Kernel: Linux 6.14.2-desktop-3omv2590
ptime: 1 hour, 54 mins
Packages: 2825 (rpm)
Shell: bash 5.2.37
Display (BOE0A31): 1920x1200 @ 60 Hz in 16" [Built-in]
Display (Q2963): 2560x1080 @ 60 Hz in 29" [External]
DE: KDE Plasma 6.3.4
WM: KWin (X11)
WM Theme: Breeze
Theme: Breeze (Light) [Qt], Breeze [GTK2/3]
Icons: breeze [Qt], breeze [GTK2/3/4]
Font: Noto Sans (10pt) [Qt], Noto Sans (10pt) [GTK2/3/4]
Cursor: Breeze_Light (24px)
Terminal: konsole 25.4.0
Terminal Font: Liberation Mono (11pt)
CPU: 12th Gen Intel(R) Core™ i7-1255U (12) @ 4.70 GHz
GPU: Intel Iris Xe Graphics @ 1.25 GHz [Integrated]
Memory: 2.64 GiB / 7.34 GiB (36%)
Swap: 0 B / 4.17 GiB (0%)
Disk (/): 81.18 GiB / 468.09 GiB (17%) - ext4
Local IP
Battery (L21M3PE1): 94% [AC Connected]
Locale: en_US.UTF-8

This is also going to be moved to Development

Hi @tanker3278,

I tested your code under two different JDK’s, and got some interesting results. I am on Rock 6 just like you, but my display server is set to Plasma6 Wayland.

My default JDK is Adoptium’s Temurin 17, and running your code works without any issues. The interesting result occurs when I switch to the packaged JDK 21, I get the same error as you. I decided to try it with the java-17-openjdk package for comparison. Surprisingly it did not work, however, the error lead me to the solution.

You need to install the java-<version>-openjdk-gui package. After installing the gui package for both 17 and 21, I was successful in compiling and executing your code under both versions.

Please give it a try and let us know. Best regards

Finally had some time again last night to work on it.

In addition, I also decided to change from Rock to Cooker. Did the conversion before starting on it. Not really any noticeable differences (on my machine anyway).

After getting Cooker up and running, immediately did the jdk install and then did the GUI install you suggested. Everything worked great after that!

I ran back through all 25 of the BroCode tutorials files I had and had zero issues on any!

Thank you so much for the help!

Solved!

1 Like