aspose file tools*
The moose likes Servlets and the fly likes ImageIcon problem! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "ImageIcon problem!" Watch "ImageIcon problem!" New topic
Author

ImageIcon problem!

Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1066
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
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61218
    
  66

If your server is a unix variant, I'm pretty sure you need to have X11 installed for imaging to work.
hth,
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1066
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
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61218
    
  66

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
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

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.
Mark Bensing
Ranch Hand

Joined: Mar 09, 2003
Posts: 40
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 ]
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1066
Thanks to all!
The web hosting company installed X11 and Imageicon("path").getImage() now works!
Thanks again.
-- Mike
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ImageIcon problem!