4

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).

Eng.Fouad
  • 115,165
  • 71
  • 313
  • 417
user1513121
  • 41
  • 1
  • 1
  • 2
  • 4
    Can you add code, full exception text, and Ubuntu/Java version numbers? – SomeKittens Jul 09 '12 at 21:10
  • [HeadlessException](http://docs.oracle.com/javase/7/docs/api/java/awt/HeadlessException.html) is "Thrown when code that is dependent on a keyboard, display, or mouse is called in an environment that does not support a keyboard, display, or mouse." Is your laptop hooked up to an external monitor and the laptop screen itself off? If so, that *may* be causing problems. – Talon876 Jul 09 '12 at 21:26
  • That would be quite strange, Talon876. The environment need only *support* the I/O devices - they don't need to be present. – Synesso Jul 10 '12 at 07:34

2 Answers2

3

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.

Community
  • 1
  • 1
Synesso
  • 37,610
  • 35
  • 136
  • 207
1

Look @ following link that might help:

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

Java SE
  • 2,073
  • 4
  • 19
  • 25