[SOLVED] Caused by: java.awt.HeadlessException when trying to create a SWING/AWT frame from Spring Boot

In Spring Boot, when you try to create a Swing frame from the component that is the entry point of your app, you will get

Caused by: java.awt.HeadlessException

To solve this, in your Application class in main, instead of:

SpringApplication.run (Application.class, args)

use

SpringApplicationBuilder builder = new SpringApplicationBuilder(Application.class);
builder.headless(false);
ConfigurableApplicationContext context = builder.run(args);

11 thoughts on “[SOLVED] Caused by: java.awt.HeadlessException when trying to create a SWING/AWT frame from Spring Boot

  1. Even SpringBuilder headless is decalared as false , still i get same exception .Caused by: java.awt.HeadlessException: null .. Researched a lot but no luck

    Like

  2. after handling this exception in application it’s working but making war file and deploying in external server it’s getting same exception so how to handle this exception in this situation

    Like

Leave a comment