This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I've Googled around, but I'm trying to figure out the right way to fix this. We have Java code that uses java.awt (Graphics2D stuff) to generate an image, and we've ported the code over to Linux, but now we're getting this error when our web app tries to generate the image:
What's the best way to fix this? We're running just about the latest release, I think: Red Hat Enterprise Linux 3. Is there a quick and easy way to install something, or what?
I Googled around some more, and then I went onto the app server as root and did the following:
#export DISPLAY=localhost:0.0 #xhost + access control disabled, clients can connect from any host
I'm not sure if that fixed the problem. Now the error changed to the stuff down below, but I don't think it fixed it, because in my app logs I'm seeing NullPointerExceptions when trying to do stuff with the image:
Ok, I'll read up on this headless stuff. I remember seeing a post somewhere that implied that folks were hoping there'd be no need for the headless stuff once the JDK 1.4 came out...
Joined: Jun 13, 2000
Headless was introduced in JDK 1.4 prior to that, you needed to run a X Vertual Frame Buffer (xvfb) plus properly export the DISPLAY variable in the Startup Script of your server. Both of these are fairly easy for someone familar with X-Windows.
Joined: Jul 15, 2003
I added export CATALINA_OPTS=-Djava.awt.headless=true to /etc/profile and then I typed the following as root:
export DISPLAY=localhost:0.0 xhost +
Doing all of that worked on one Red Hat box, but on another machine that was recently installed from the same Red Hat CD, I'm getting this:
java.awt.HeadlessException at sun.awt.HeadlessToolkit.getScreenResolution(HeadlessToolkit.java:184) at com.idautomation.linear.BarCode.(com/idautomation/linear/BarCode)
They say they've fixed the error with their barcode-generating code, but I don't see why I'd have a problem with it on one machine and not another. We got this code from them a couple of years ago, so I don't have a clue what our order number would be or anything like that to get the update. However, how likely is it that their code would give us an error on one machine but not a nearly identical machine? I'm just trying to scrounge around and see if there's anything I can do to try to fix this...
Joined: Jul 15, 2003
Bought the upgraded version...not sure why the old one worked on one Linux box but gave that HeadlessException on a nearly identical Enterprise Red Hat machine. Oh well.