Running a Java GUI application through a Linux terminal


I'm on Ubuntu trying to run a Java GUI application through the terminal. I'm getting a HeadlessException when I try to run it. Below is the stack trace:

Exception in thread "AWT-EventQueue-0" java.awt.HeadlessException
    at java.awt.GraphicsEnvironment.checkHeadless(
    at java.awt.Window.<init>(
    at java.awt.Frame.<init>(
    at java.awt.Frame.<init>(
    at javax.swing.JFrame.<init>(
    at gui.ImageViewer.<init>(
    at displayrunner.DisplayRunner$
    at java.awt.event.InvocationEvent.dispatch(
    at java.awt.EventQueue.dispatchEventImpl(
    at java.awt.EventQueue.access$000(
    at java.awt.EventQueue$
    at java.awt.EventQueue$
    at Method)
    at java.awt.EventQueue.dispatchEvent(
    at java.awt.EventDispatchThread.pumpOneEventForFilters(
    at java.awt.EventDispatchThread.pumpEventsForFilter(
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(
    at java.awt.EventDispatchThread.pumpEvents(
    at java.awt.EventDispatchThread.pumpEvents(

I tried export DISPLAY=:0.0 before running the app, but that had no effect. How do you run a GUI application through Bash?

I guess you only have default-jre-headless package installed, check that you have default-jre.