问题
I am running into errors such as the following:
Exception in thread "Thread-1" java.lang.IncompatibleClassChangeError: Found class com.sun.image.codec.jpeg.JPEGImageEncoder, but interface was expected
I have built my JAR's using Sun JDK and I am running on OpenJDK. I am kind of stuck with this environment.
Is there an easy way around this? Do I have to compile and run the code on OpenJDK?
回答1:
com.sun.image.codec.jpeg.JPEGImageEncoder
by the name is a Sun-specific package so there's no guarantee (in fact it's highly unlikely) that any other JDK\JRE will provide that class. Are you using it directly? If so, you're limiting your application to Sun-only JVMs.
回答2:
By the looks of it, Jasper Reports is drilling down and using internal classes / methods that it shouldn't use. This apparently doesn't work on all platforms ... which is not surprising because Sun / Oracle specifically state that doing this is liable to break.
What should you do?
Check the Supported Platforms datasheet. I note that it lists OpenJDK 6, but not OpenJDK 7. Maybe you should stick with the JasperSoft supported platforms.
I found this page which seems to talk about this problem ... or something rather similar ... and offers a workaround.
来源:https://stackoverflow.com/questions/15260446/difference-between-sun-jdk-and-open-jdk