For Tomcat development, are there any special "lib" files needed to support ImageIcon().getImage? I have code that will not work on a web server (see the line code below (orig is a full server path name to a file)). Image inImage = new ImageIcon(orig).getImage(); This line of code never returns even for the first file, but runs fine on a XP Pro and M$ Windows 2000 Pro box. Any ideas what to try would be greatly appreciated. I've verified that the path is valid and the file actually exists. I'm not sure what exceptions it can throw other than file not found and a general IOException (neither of which it's throwing -- I'm catching both). The code just doesn't "do" anything on the web server and crashes the first time. Thanks very much in advance. -- Mike
I'm sorry, but I don't know what X11 is. This is a web hosting company that supports servlets, JSP all under Tomcat 4.1.18. The code that is failing: Image inImage = new ImageIcon(orig).getImage(); (where orig is a full server path to the image) Is from the javax.swing.ImageIcon library. Is it possible this call could block or do you still think it may need X11 installed? Thanks in advance for your clarification. -- Mike
X11 is a unix windowing system. I'm remembering (from a previous job) that it needed to be installed on Linux servers for the AWT imaging sub-system to work. Now bear in mind that server management is not my forte and I could be completely off my gourd. Best thing to do is to chat with the sys admin of your hosting service. hth, bear
Yep, you geed a User Interface on the machine before it will support AWT, since this relies on native stuff. I ran into the same problem and haven't had a chance to work it out yet, but I found this handy work around.
Just an FYI regarding the posts about X11 being required for graphics functions on Unix. J2SE 1.4 introduced headless graphics support so that X11 is no longer required. A quote from Java bug 4281163 which was the basis for this change:
'Headless' operation refers to the ability to run a Java program without a monitor, mouse or keyboard. In unix environments, it usually means that X or an equivalent windowing system does not have to be present. Headless Java operation would mean that a server side Java program should be able to use the full J2SE or J2EE API without a GUI environment being present. This means that all AWT calls to manipulate components, graphics, fonts, printing etc. should be functional.
I ran into the X11 requirement in a past job, but I have never had a chance to try the new headless support so I dont know how well it works. Mark [ April 07, 2003: Message edited by: Mark Bensing ]
Joined: Jul 12, 2002
Thanks to all! The web hosting company installed X11 and Imageicon("path").getImage() now works! Thanks again. -- Mike