ExceptionInInitializerError when using ImageIO.read(file) under WINXP home

P

Piet71

Hello,
I have written a short program to display bitmaps in JFrames. The
program works fine under Win 2000 Professional but fails under WinXP
home on my laptop. Both PC´s have java 1.4.2_08 installed. The laptop
came with java 1.4.2_03 installed that was removed prior to
installation of the newer version. Here is the program:
import java.awt.*;
import java.awt.font.*;
import java.awt.geom.*;
import javax.swing.*;
import java.io.*;
import javax.imageio.*;
import java.lang.Math.*;
import java.util.Random;

public class BitmapPanelDemo extends JFrame{
BitmapPanelDemo(String title){
super(title);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//getContentPane().add(new TransformPanelLine());
getContentPane().add(new BitmapPanel("filename.JPG"));
}
public static void main(String[] args){
try{
BitmapPanelDemo bpd = new BitmapPanelDemo("Bitmap Panel Demo");
bpd.pack();
bpd.setVisible(true);
}
catch(Throwable e){
e.printStackTrace();
}

}
}


class BitmapPanel extends JComponent{
private Image image;
private Dimension preferredSize = new Dimension(20,50);
BitmapPanel(String fileName){
try{
this.image = ImageIO.read(new File(fileName));
this.preferredSize.setSize(image.getWidth(this),image.getHeight(this));
}
catch(IOException ioe){
System.out.println("Error on loading image!");
}
}
public void paintComponent(Graphics g){
try{
g.drawImage(this.image,0,0,this);
}
catch(NullPointerException npe){
g.drawString("No Image",0,20);
}
}
public Dimension getPreferredSize(){
return this.preferredSize;
}
}
and here is the stack trace:
java.lang.ExceptionInInitializerError
at
com.sun.imageio.plugins.jpeg.JPEGImageReader.<clinit>(JPEGImageReade
..java:191)
at
com.sun.imageio.plugins.jpeg.JPEGImageReaderSpi.createReaderInstance
JPEGImageReaderSpi.java:89)
at
javax.imageio.spi.ImageReaderSpi.createReaderInstance(ImageReaderSpi
java:296)
at
javax.imageio.ImageIO$ImageReaderIterator.next(ImageIO.java:488)
at javax.imageio.ImageIO.read(ImageIO.java:1381)
at javax.imageio.ImageIO.read(ImageIO.java:1270)
at BitmapPanel.<init>(BitmapPanelDemo.java:36)
at BitmapPanelDemo.<init>(BitmapPanelDemo.java:15)
at BitmapPanelDemo.main(BitmapPanelDemo.java:19)
Caused by: java.lang.IllegalArgumentException: Can't load standard
profile: GRA
..pf
at java.awt.color.ICC_Profile$2.run(ICC_Profile.java:826)
at java.security.AccessController.doPrivileged(Native Method)
at
java.awt.color.ICC_Profile.getStandardProfile(ICC_Profile.java:819)
at java.awt.color.ICC_Profile.getInstance(ICC_Profile.java:796)
at java.awt.color.ColorSpace.getInstance(ColorSpace.java:306)
at
javax.imageio.ImageTypeSpecifier$Grayscale.<init>(ImageTypeSpecifier
java:667)
at
javax.imageio.ImageTypeSpecifier.createGrayscale(ImageTypeSpecifier.
ava:739)
at
javax.imageio.ImageTypeSpecifier.<clinit>(ImageTypeSpecifier.java:14
)
... 9 more
Press any key to continue...

The line 191 from JPEGImageReader.java is:
//from JPEGImageReader.java

static {
defaultTypes[JPEG.JCS_GRAYSCALE] =
ImageTypeSpecifier.createFromBufferedImageType
(BufferedImage.TYPE_BYTE_GRAY);
//more stuff
}
The reason for the error seems to be a missing file but I have been
unable to support that assumption or even figure out where the missing
file should be placed. The string "GRAY.pf" occurs neither in the
JPEGImageReader.java nor in the ImageTypeSpecifier.java. Has anyone
encountered a similar problem or knows in more detail the reason for
the error above?
Many thanks in advance

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,999
Messages
2,570,246
Members
46,839
Latest member
MartinaBur

Latest Threads

Top