Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

java.awt.HeadlessException

Posted on 2003-11-13
5
Medium Priority
?
600 Views
Last Modified: 2013-11-24
i have a servlet which was used to generate images on the fly.  Locally, the servlet worked fine.  However, once deployed on the app server, it crashes resulting in the stack trace below.  It seems the classes I'm using (ImageJ) to create the images, builds the image using a heavy-weight component (jframe) and an exception is thrown because that component requires a mouse, keyboard, monitor, etc... and apparently this server doesn't have any of that.

Does anyone knwo how I can 'get around' this exception?  I've read that setting the -Djava.awt.Headless=true option has worked for some, but many have said it did nothing for them.  I'm assuming that I can set this property via System.setProperty("java.awt.Headless", true) and it should have the same effect as command-line parameter, correct?

Please, anything you can offer I would appreciate.
0
Comment
Question by:sapientconceptions
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 

Author Comment

by:sapientconceptions
ID: 9745517
Sorry, forgot the stack (or the relevant part anyway):

java.awt.HeadlessException
      at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:121)
      at java.awt.Window.(Window.java:251)
      at java.awt.Frame.(Frame.java:398)
      at java.awt.Frame.(Frame.java:363)
      at ij.process.ImageProcessor.setupFrame(ImageProcessor.java:688)
      at ij.process.ImageProcessor.getFontMetrics(ImageProcessor.java:797)
0
 
LVL 92

Expert Comment

by:objects
ID: 9745519
Depends what version of Java u are running on the server.
0
 
LVL 92

Expert Comment

by:objects
ID: 9745524
This may be an option:
http://www.eteks.com/pja/en/
0
 
LVL 35

Accepted Solution

by:
TimYates earned 1000 total points
ID: 9746346
Try running tomcat with

-Djava.awt.headless=true

in the parameters (NOTE! small "h")

Tim
0
 
LVL 35

Expert Comment

by:TimYates
ID: 9746362
Ahhhh...just saw you are creating a JFrame...

Not sure what happens with that, but I'd try the headless param first...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

596 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question