[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
[code]Caused by: java.awt.HeadlessException[/code]

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

[code]
SpringApplication.run (Application.class, args)
[/code]

use

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

Leave a Reply

Your email address will not be published. Required fields are marked *