How do I prevent a headless exception in Java?

10,854

Solution 1

Have you tried setting java.awt.headless=true? I have done this once before on Solaris with no x-server in order to use the java.awt print libraries. It worked a treat. However it was more than five years ago and I don't have the source handy.

See Setting java.awt.headless=true programmatically

PS Are you on Ubuntu server or desktop? If the latter, I'd question why Java thinks you are headless.

Solution 2

Look @ following link that might help:

http://www.theserverside.com/discussions/thread.tss?thread_id=52535

Share:
10,854
Admin
Author by

Admin

Updated on June 27, 2022

Comments

  • Admin
    Admin almost 2 years

    I have an Applet and when I try to run it on my laptop, a headless exception is thrown by Java at the line where a JFrame is created. Now I know why the JFrame normally causes the exception but my computer was not in headless mode to begin with. I'm also still not sure what headless mode entails exactly.

    I'm running Ubuntu and have a pretty recent version of java.

    Also, I have successfully created JFrames and such in Eclipse when running Windows on my laptop (if that helps).

  • Torsten
    Torsten almost 7 years
    It would be great, if you could sum up the gist of that thread in your post in the case the url will be gone in the future.
  • Alex Meiburg
    Alex Meiburg about 3 years
    Indeed, this link is now broken. What a shame they couldn't have written a bit.