3

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?

Alex K
  • 22,315
  • 19
  • 108
  • 236
reza
  • 5,972
  • 15
  • 84
  • 126
  • Is your code accessing `JPEGImageEncoder` directly? That isn't a public API. (If you are, you may want to upgrade to the absolute latest Oracle and Open JDKs. And then remove the dependencies on "private" classes.) If you really running a Sun JDK, probably about time to update that old thing. – Tom Hawtin - tackline Mar 06 '13 at 23:49
  • I am not accessing the function directly, this is all in 3rd party software jasper reports. – reza Mar 06 '13 at 23:54

2 Answers2

2

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.

Chris Thompson
  • 35,167
  • 12
  • 80
  • 109
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.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216