Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Headless Exception

 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

When i tried to call an legacy applet class , i get this exception

Exception : java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.

i have no clue about the class , except that it extends Applet. Can someone explain what this X11 all about ? When such exceptions occurs ?

 
Rob Spoor
Sheriff
Pie
Posts: 20606
60
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you trying to run the applet? Are you inside a windowed environment like KDE, GNOME, Xfce, ...? Or do you only have a terminal?

Since DISPLAY is not set (which will mostly happen automatically when starting KDE, GNOME etc) my guess is the latter, and that makes it hard to display the applet (or any GUI). Because the JVM cannot find a proper environment to display on it will throw a HeadlessException.
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Rob ,

I have added this java -Djava.awt.headless=true to skip the exception. I did this just because the use of that file is pack String arrays , and not sure why it extends Applet ?!?! so anyways Thanks and things working fine..

Does this suppression (-Djava.awt.headless=true ) has any consequences ?
 
Rob Spoor
Sheriff
Pie
Posts: 20606
60
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Balu Sadhasivam wrote:the use of that file is pack String arrays , and not sure why it extends Applet ?!?!

Bad design obviously.
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:
Balu Sadhasivam wrote:the use of that file is pack String arrays , and not sure why it extends Applet ?!?!

Bad design obviously.


Well thats part and parcel of legacy systems..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic