View Full Version : ImageIO.read of InputStream fails

July 29th, 2011, 09:45 PM
I have an issue which is only appearing on ubuntu deployments. What happens is that I pass in image data in byte[] format. I run the following code...

public byte[] resizeImage(byte[] image, String type, int maxWidth, int maxHeight) {
InputStream in = new ByteArrayInputStream(image);
BufferedImage originalImage = ImageIO.read(in);

The ImageIO.read throws an exception

Exception:javax.imageio.IIOException: Can't create cache file! at javax.imageio.ImageIO.createImageInputStream(Image IO.java:351) at javax.imageio.ImageIO.read(ImageIO.java:1341)

Any ideas?

July 29th, 2011, 11:41 PM
Which JVM are you using, openJDK or Java Sun? If it is working fine on Windows I would assume that you are using Sun on Windows and openJDK on Ubuntu (since I am fairly sure openJDK is the default).


August 1st, 2011, 04:18 PM
That was the issue.

We reloaded Ubuntu OS, then manually installed Sun Java, then our application. The error disappeared.

Thanks for the quick answer!