Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

Java or NetBeans fails because libXtst.so.6 is missing on Ubuntu

ErrorlibXtst.so.6 not found when starting a Java GUI program or NetBeans

Short answer

libXtst.so.6 comes from the Ubuntu package libxtst6, and a Java desktop program needs it to load. Install libxtst6, or install the full openjdk-21-jre package, which depends on it. A headless Java runtime leaves the library out, which is why servers and minimal images hit this error.

  • Applies to Ubuntu 24.04, OpenJDK 21, NetBeans
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Ask the system whether the library is installed and which Java packages are present. An empty answer for the first command means the library is missing.

    ldconfig -p | grep libXtst
    dpkg -l | grep -E 'openjdk|libxtst'
  2. 2Match what you see, then jump to its fix

    1. 1ldconfig -p prints nothing for libXtst, and dpkg shows no libxtst6.The libxtst6 package is not installedFix
    2. 2dpkg lists openjdk-21-jre-headless but not openjdk-21-jre.Java was installed as a headless runtime, which carries no GUI librariesFix

What does the error look like?

  • libXtst.so.6 not found when starting a Java GUI program or NetBeans
  • Can't find/install libXtst.so.6

Cause 1 of 2

The libxtst6 package is not installed

1Check

On Ubuntu 24.04 (amd64) the file /usr/lib/x86_64-linux-gnu/libXtst.so.6 belongs to the package libxtst6, described as the X11 testing record-extension library.

dpkg -L libxtst6 2>&1 | head

2Fix

Install the package, then start the program again.

sudo apt update
sudo apt install libxtst6

3Verify

The library is now known to the loader.

ldconfig -p | grep libXtst

Confirmed by packages.ubuntu.com

Did this fix it?

Cause 2 of 2

Java was installed as a headless runtime, which carries no GUI libraries

1Check

The package openjdk-21-jre depends on openjdk-21-jre-headless and also on libxtst6, libxi6, libxrender1 and other desktop libraries. The headless package alone gives the core runtime without them.

dpkg -l | grep -E 'openjdk-21-jre'

2Fix

Install the full runtime on any machine that opens Java windows (a desktop, for example). Keep headless on machines that only run services.

sudo apt install openjdk-21-jre

3Verify

Both the runtime and the library are present.

dpkg -l | grep -E 'openjdk-21-jre |libxtst6'
ldconfig -p | grep libXtst

Confirmed by packages.ubuntu.com

Did this fix it?

How do I stop it coming back?

  • Use the headless Java package on servers and containers that never show a window, and the full one only where a GUI is needed.
  • Install GUI-heavy tools such as NetBeans from a package or installer that declares its dependencies, so apt brings the libraries in.
  • Write the libxtst6 line into your provisioning script or Dockerfile once the app needs it.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Related fixes

Servers

dnf cannot install MySQL on Amazon Linux 2023

dnf cannot find a mysql-server package on Amazon Linux 2023

Amazon Linux 2023 documents MariaDB, not MySQL, as its database server, with packages named mariadb105 and mariadb105-server.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.