Why does my Java Swing app throw an error?

Issue

I see an error stating either Exception in thread "main" java.awt .HeadlessException or No X11 DISPLAY variable was set, but this program performed an operation which requires it..

Resolution

Heroku is a headless platform, and connect support GUI applications that use javax.swing.JFrame, java.awt.Window.