Posted by: Chyne on: July 12, 2009
java.lang.IncompatibleClassChangeError: Found class com.sun.image.codec.jpeg.JPEGImageEncoder, but interface was expected
Root Cause
If you found this error appears in the log file, the biggest possibility and maybe the only reason that this exception being thrown is you are using the OpenJDK instead of Sun JDK. Well, the exception message is obvious to tell you that the com.sun.image.codec.jpeg.JPEGImageEncoder is a class in OpenJDK whereas it is implemented as an interface in Sun JDK.
Further Investigation
After a further research, I just figured out that this interface has been removed from the JDK 6 API documentation and it has been completely being removed in JDK 7. It has been discussed as a reported bug in the Sun site: Retire the non-standard package com.sun.image.jpeg.codec. That’s the reason I don’t even can find the documentation for com.sun.image.codec.jpeg.JPEGImageEncoder in JDK 6 API documentation.
Besides that, as mentioned in the discussion, it has been buried in a separate API heading which I can’t find this package inside the JDK 1.4 API documentation. However, if you are curious to know what the methods are being implemented in the Interface JPEGImageEncoder, you can refer to the following javadocs:
Further Zooming
Please take note that in the javadocs, the documentation had specified the following for the introduction of this Interface:
Note that the classes in the com.sun.image.codec.jpeg package are not part of the core Java APIs. They are a part of Sun’s JDK and JRE distributions. Although other licensees may choose to distribute these classes, developers cannot depend on their availability in non-Sun implementations. We expect that equivalent functionality will eventually be available in a core API or standard extension.