Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm working on XUbuntu 13.04 and developing swing applications. As I just wanted to try that application I ran into java.lang.NoClassDefFoundError: Could not initialize class java.awt.Toolkit on startup.

I've found several questions about server/client vms and noticed that I have a server VM and that for Linux 64 there is no client VM anymore. But nevertheless IMHO this problem shouldn't depend on which VM I'm running on.

Has anybody else noticed that problem and has solved it? What am I doing wrong? With 64bit jdk everything works fine, but when I try to use the 32bit jdk the startup fails.

Thanks in advance!

P.S.: Java version is 1.7.0_25 and same with 1.7.0_09

EDIT

When using headless mode, the following exceptions occur:

java.lang.reflect.InvocationTargetException
    at java.awt.EventQueue.invokeAndWait(EventQueue.java:1272)
    at java.awt.EventQueue.invokeAndWait(EventQueue.java:1247)
    at javax.swing.SwingUtilities.invokeAndWait(SwingUtilities.java:1349)
    at Main.main(Main.java:218)
Caused by: java.awt.HeadlessException
    at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:207)
    at java.awt.Window.<init>(Window.java:535)
    at java.awt.Frame.<init>(Frame.java:420)
    at java.awt.Frame.<init>(Frame.java:385)
    at javax.swing.JFrame.<init>(JFrame.java:180)
    at ..MyFrame.<init>(MyFrame.java:23)
like image 650
Bertram Nudelbach Avatar asked Aug 07 '13 09:08

Bertram Nudelbach


1 Answers

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

sudo apt-get install openjdk-11-jre
like image 59
wedesoft Avatar answered Sep 25 '22 22:09

wedesoft