I have a Java program when I compile it I get the following error
[javac] ...\MyClass.java:33: package com.sun.image.codec.jpeg does not exist
[javac] import com.sun.image.codec.jpeg.*;
[javac] ^
what can I do ?
What is the correct way of writing an image file now that the com.sun package is deprecated.
I had this problem when compiling with JDK 7. Strange enough Eclipse did not show this error, only javac did. The answer can be found in this Stackoverflow answer: javac uses a special symbol table that does not include all Sun-proprietary classes, and suppliying -XDignore.symbol.file
makes the problem go away.
Of course, a much better solution is to rewrite the code without using the proprietary classes, but to support JDK 7 quickly, this option works.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With