Solved

java.awt.HeadlessException

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ejb wildfly example 2 104
add projects t working set in maven 2 64
How to retrieve the HTTPServletResponse header field in script tag 1 40
maximize the sum of fractions 33 70
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

738 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