Solved

java.awt.HeadlessException

Posted on 2003-11-13
5
575 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 250 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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

724 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