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
Take a look here Link
1. Open project properties.
2. Select Java Build Path node.
3. Select Libraries tab.
4. Remove JRE System Library.
5. Add Library JRE System Library.
As Milad
suggested
Even though this WILL work, this goes against all recommended Java Runtime policies. The best practice is to avoid using rt.jar (or any other Sun supplied runtime library for that matter, like tools.jar)
These are in rt.jar, the jar file used as run-time facilities by the JVM, and I would strongly recommend you against adding it as a dependency to your project.
See why here.
The correct way to do what you want to do is described here.
Maybe your jre system library is 1.8
or eclipse: Project Properties > java compiler > Errors/Warnings > Deprecated API
change Error to ignore/warning
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.