Import Com.Sun.Image.Codec.Jpeg.*

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 Retired

Description: 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 the com.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



Leave a reply



Submit