Exception in thread "main" java.awt.HeadlessException

Solution Verified - Updated -

Issue

  • How to confirm you are using headless mode?
  • How to set up headless mode in Java explicitly?
  • Customer getting below error while starting the GUI of Java application :
[user@user bin]# exampleGUIApplicaion
openjdk version "1.8.0_282"
OpenJDK Runtime Environment (build 1.8.0_282-b08)
OpenJDK 64-Bit Server VM (build 25.282-b08, mixed mode)
Exception in thread "main" java.awt.HeadlessException
        at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
        at java.awt.Window.<init>(Window.java:536)
        at java.awt.Frame.<init>(Frame.java:420)
        at java.awt.Frame.<init>(Frame.java:385)
        at javax.swing.SwingUtilities$SharedOwnerFrame.<init>(SwingUtilities.java:1763)
        at javax.swing.SwingUtilities.getSharedOwnerFrame(SwingUtilities.java:1838)
        at javax.swing.JWindow.<init>(JWindow.java:187)
        at javax.swing.JWindow.<init>(JWindow.java:139)
        at xxx.client.C_MainFrame$18.<init>(C_MainFrame.java:1048)
        at xxx.client.C_MainFrame.showSplash(C_MainFrame.java:1048)
        at xxx.client.C_MainFrame.main(C_MainFrame.java:1008)

Environment

  • OpenJDK 1.8

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content