java.lang.NoClassDefFoundError: Could not initialize class java.awt.Toolkit

Had the missing awt library problem on Ubuntu 20.04. Fixed it by installing openjdk-11-jre:

sudo apt-get install openjdk-11-jre

Okay, finally I've found the answer. Thanks for the effort! The problem is that I had libxtst6 installed but only the 64bit-version of it.

sudo apt-get install libxtst6:i386 did the trick for me.

How did I find this answer? I ldded around a bit, but nothing, as you can see in the following:

$ ldd jdk1.7.0_25_x86/jre/lib/i386/xawt/libmawt.so
    linux-gate.so.1 =>  (0xf7769000)
    libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xf76ee000)
    libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xf76c2000)
    libawt.so => jdk1.7.0_25_x86/jre/lib/i386/xawt/../libawt.so (0xf760f000)
    libXext.so.6 => /usr/lib/i386-linux-gnu/libXext.so.6 (0xf75fd000)
    libX11.so.6 => /usr/lib/i386-linux-gnu/libX11.so.6 (0xf74c9000)
    libXrender.so.1 => /usr/lib/i386-linux-gnu/libXrender.so.1 (0xf74bf000)
    libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xf74ba000)
    libXtst.so.6 => /usr/lib/i386-linux-gnu/libXtst.so.6 (0xf74b2000)
    libXi.so.6 => /usr/lib/i386-linux-gnu/libXi.so.6 (0xf74a2000)
    libjava.so => jdk1.7.0_25_x86/jre/lib/i386/xawt../libjava.so (0xf747e000)
    libjvm.so => not found
    libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf72d5000)
    /lib/ld-linux.so.2 (0xf776a000)
    libjvm.so => not found
    libxcb.so.1 => /usr/lib/i386-linux-gnu/libxcb.so.1 (0xf72b3000)
    libjvm.so => not found
    libverify.so => java/jdk1.7.0_25_x86/jre/lib/i386/xawt/../libverify.so (0xf72a7000)
    libXau.so.6 => /usr/lib/i386-linux-gnu/libXau.so.6 (0xf72a2000)
    libXdmcp.so.6 => /usr/lib/i386-linux-gnu/libXdmcp.so.6 (0xf729b000)
    libjvm.so => not found

So that was the point when I ended trusting my IDE and started a sample application on the command line. And the command line again was nice to me:

$ jdk1.7.0_25_x86/bin/java Main
Exception in thread "main" java.lang.UnsatisfiedLinkError: jdk1.7.0_25_x86/jre/lib/i386/xawt/libmawt.so: libXtst.so.6: cannot open shared object file: No such file or directory
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1957)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1882)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1843)
    at java.lang.Runtime.load0(Runtime.java:795)
    at java.lang.System.load(System.java:1061)
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1957)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1882)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1864)
    at java.lang.Runtime.loadLibrary0(Runtime.java:849)
    at java.lang.System.loadLibrary(System.java:1087)
    at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:67)
    at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:47)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.awt.Toolkit.loadLibraries(Toolkit.java:1646)
    at java.awt.Toolkit.<clinit>(Toolkit.java:1668)
    at java.awt.Component.<clinit>(Component.java:595)
    at Main.main(Main.java:5)