Solved

java.awt.HeadlessException

Posted on 2003-11-13
5
507 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
  • 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Fibonacci challenge 11 84
What is JNDI datasource in spring 1 38
groovy example issue 10 67
maven example error 3 36
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
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:

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now