This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes HeadlessException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "HeadlessException" Watch "HeadlessException" New topic
Author

HeadlessException

Jon Camilleri
Ranch Hand

Joined: Apr 25, 2008
Posts: 659

Can you provide an example where a HeadlessException was thrown, and the environment and code involved?



Jon
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19557
    
  16

Suppose you have a UNIX / Linux server. This does not have any desktop environment like KDE or GNOME running; there's not even a so-called X server running for displaying anything graphically. In other words, you cannot display any frame, dialog, or other components on the screen. All that can be displayed is text through System.out and System.err.

Now suppose that on this system you want to display a frame. Without anything to display the frame on (remember, no desktop environment), how should the system display this frame? The answer: it simply can't, and throws an exception.

If you have such a system and you still need to use some of the classes in AWT / Swing (there's nothing wrong with using a Rectangle or Dimension, for instance), and the system is throwing HeadlessExceptions, you can pass the "-Djava.awt.headless=true" to the JVM to disable some of these exceptions. Still not all, because again, if there's nothing to display a frame on, the frame simply cannot be displayed.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HeadlessException
 
Similar Threads
Is possible change icon of Ok's botton in JOPtionPane, How?
works on WinXP jdk 1.6 but not Linux jdk 1.5
Image Resizing Help
How to solve this problem?
X11 window server error on linux!