Unable to run Java GUI programs with Ubuntu
I stopped getting this exception when I installed default-jdk
using apt
. I'm running Ubuntu 14.04 (Trusty Tahr), and the problem appears to have been the result of having a "headless" Java installed. All I did was:
sudo apt-get install default-jdk
In my case
-Djava.awt.headless=true
was set (indirectly by a Maven configuration). I had to actively use
-Djava.awt.headless=false
to override this.
Ubuntu has the option to install a headless Java -- this means without graphics libraries. This wasn't always the case, but I encountered this while trying to run a Java text editor on 10.10 the other day. Run the following command to install a JDK that has these libraries:
sudo apt-get install openjdk-6-jdk
EDIT: Actually, looking at my config, you might need the JRE. If that's the case, run:
sudo apt-get install openjdk-6-jre