what library I need so I can access this com.sun.image.codec.jpeg in Java?

前端 未结 4 2081
忘掉有多难
忘掉有多难 2021-02-07 21:29

I\'m creating an image watermarking program in java and I imported the followings:

import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPE         


        
4条回答
  •  旧时难觅i
    2021-02-07 22:01

    The problem is, that you're importing libraries from the sun.com.* package. Oracle actually discourages the use of these packages, since they could be removed in future releases or may not be available in all JVM implementations.

    It's possible that your IDE (which one are you using?) is configured for generating errors if you try to import sun.com.* libraries, in that case a configuration change will allow you to use those libraries, but it wouldn't be a good idea anyway. You should look for other alternatives to the functionality you seek, using libraries with no access restrictions.

    Also, if what you want is to simply read or write a JPEG file, take a look at the ImageIO class, there are plenty of useful methods in there.

提交回复
热议问题