There are some tool classes related to picture processing in the project, and within the Eclipse development tool, there is no problem with the program, it can be used normally, the project is not error-free, but when you compile and package with Maven, you will get an error:
Package com.sun.image.codec.jpeg does not exist.
From the name of the package, is the sun company before some of the class, in some older code, often used to deal with the image format conversion, interception and so on.
Similar to the following code:
1 FileOutputStream fos= new FileOutputStream(targetFile);
2 JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(fos);
3 encoder.encode(image);
In fact, the simplest way to solve this compilation error is to use the new tool class: ImageIO, which provides a variety of write methods that can be used in a variety of situations to achieve the same purpose.
Of course, there are other ways, in the compilation environment to add the corresponding dependency package, the individual think or use the new tool class better, the new tool class must have its unique (PS: no specific see the corresponding implementation, look for time to see).
When Maven compiles a project: report Com.sun.image.codec.jpeg does not exist