问题
I have a program that makes use of the following method to get a scaled instance of an image icon:
public ImageIcon createScaledImageIcon(String filename) {
ImageIcon icon = new ImageIcon(filename);
Image image = icon.getImage().getScaledInstance(cardWidth, cardHeight, Image.SCALE_SMOOTH);
icon.setImage(image);
return icon;
}
I don't know if it's the source of the problem or not. But i get the following error messages:
Exception in thread "Image Fetcher 0" java.lang.UnsatisfiedLinkError: sun.awt.image.ImageRepresentation.setBytePixels(IIII[BIILsun/awt/image/ByteComponentRaster;I)V at sun.awt.image.ImageRepresentation.setBytePixels(Native Method)
at sun.awt.image.ImageRepresenation.setPixels(Unknown Source)
at sun.awt.image.ImageDecoder.setPixels(Unknown Source)
at sun.awt.image.GIFImageDecoder.sendPixels(Unknown Source) ...
Let me know if there is any other information I could include that might be of use.
回答1:
Try reinstalling the latest version of Java. Your installation may have been incomplete/corrupt (read similar experience).
回答2:
A user at this link suggests that this error may be the result of receiving a Java response and not rebooting. Whether "rebooting" referes to the entire computer, or just restarting java is unknown, though.
回答3:
I had this same problem with a Squirrel SQL install on a Windows machine. It turned out that the cause was the environment setting for the PATH. I had set JAVA_HOME to point to the Java version I installed, but there was another version of Java in the path earlier than the one I had installed (which was sitting at the end of the path).
So my JAVA_HOME setting was not right for the version of Java which was actually being run at the command line when you typed "java".
If you see this, you might try making sure that your JAVA_HOME environment variable points to the Java you installed and make sure that it appears first in your path.
回答4:
javadoc says, Thrown if the Java Virtual Machine cannot find an appropriate native-language definition of a method declared native.
guess java does not know how to read the image u specified.. use a .gif format.
来源:https://stackoverflow.com/questions/2414425/java-unsatisfiedlinkerror-awt-image