import com.sun.image.codec.jpeg.*
Why are you using classes in the package com.sun.image.codec.jpeg
? You are not supposed to use those classes directly: Why Developers Should Not Write Programs That Call 'sun' Packages.
What does your program do? Does it just try to read or write a JPG image? That's very easy with the ImageIO
API. See this tutorial: Writing/Saving an Image.
Addition - The package com.sun.image.codec.jpeg
has been removed in Java 7 as mentioned in the Java SE 7 and JDK 7 Compatibility Guide.
Synopsis: The Non-standard
com.sun.image.codec.jpeg
Package is RetiredDescription: The
com.sun.image.codec.jpeg
package was added in JDK 1.2 (Dec 1998) as a non-standard way of controlling the loading and saving of JPEG format image files. This package was never part of the platform specification and it has been removed from the Java SE 7 release. The Java Image I/O API was added to the JDK 1.4 release as a standard API and eliminated the need for thecom.sun.image.codec.jpeg
package.
what library I need so I can access this com.sun.image.codec.jpeg in Java?
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)
What to replace com.sun.image.codec.jpeg classes with?
How about this one?
import javax.imageio.ImageIO;
BufferedImage image = ImageIO.read(file);
Sun JPEGImageEncoder compilation in Gradle
From what I can tell, the JDK compiler API (which is what the JavaCompile
task uses) silently ignores the -XDignore.symbol.file
flag (I've also seen this for some other options). For now, the only solution that I'm aware of is to fall back to the Ant based compiler, even though it's deprecated.
EDIT: Another option is to force the JavaCompile
task to use the javac
command line compiler:
compileJava {
options.fork = true
options.forkOptions.executable = "javac" // assumes that javac is on PATH
options.compilerArgs << "-XDignore.symbol.file"
}
Related Topics
How to Mix --Class-Path and --Module-Path in Javac (Jdk 9)
Centering Text in a Jtextarea or Jtextpane - Horizontal Text Alignment
How to Cause a Child Process to Exit When the Parent Does
Convert Two Dimensional Array to List in Java
How to Fix Invalid Byte 1 of 1-Byte Utf-8 Sequence
How to Compile Jrxml to Get Jasper
How to Iterate Over a Priorityqueue
Difference Between an Unbound Wildcard and a Raw Type
Error 415 Unsupported Media Type: Post Not Reaching Rest If JSON, But It Does If Xml
Calling Base Class Overridden Function from Base Class Method
Adding New Paths for Native Libraries at Runtime in Java
How to Clone a Generic List in Java
Extended Server_Name (Sni Extension) Not Sent with Jdk1.8.0 But Send with Jdk1.7.0