[Solved] Linux deployment Tomcat error does not support java.lang.NoClassDefFoundError: com/sun/image/codec/jpeg/JPEGCodec

Since the new version of jdk1.8 no longer supports JPEGCodec, an error is reported, and the method needs to be modified
1.——————————- ———————
JPEGImageDecoder jpegDecoder = JPEGCodec.createJPEGDecoder(is);
BufferedImage buffImg = jpegDecoder.decodeAsBufferedImage();
Replaced with the new method
BufferedImage buffImg=ImageIO.read (is);
2.——————————————– ———
JPEGImageEncoder en = JPEGCodec.createJPEGEncoder(os);
en.encode(buffImg); Replace with the
new method
ImageIO.write(buffImg, “jpeg”, os);
——- ——————-end—————————— –
If the start is also being given, the following description is not provided cache directory tomcat
1, the new temp directory in tomcat;
2, and a similar method, by ImageIO.setCacheDirectory (cacheDirectory); set any, present in the cache directory
3. ImageIO uses the cache directory by default, which can be set by ImageIO.setUseCache(false), change the cache strategy, do not use file directory cache, use memory

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *