When Maven compiles a project: report Com.sun.image.codec.jpeg does not exist

Source: Internet
Author: User



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


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.