views:

382

answers:

3

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.

A: 

Which JDK are you using? I think that this package is not a requirement and will only be available in Sun's JDK. This discussion explains.

You may be able to download the jar file and include it on your path file separately if you really want to use it though.

According to docs:

Note that the classes in the com.sun.image.codec.jpeg package are not part of the core Java APIs. They are a part of Sun's JDK and JRE distributions. Although other licensees may choose to distribute these classes, developers cannot depend on their availability in non-Sun implementations. We expect that equivalent functionality will eventually be available in a core API or standard extension.

Vincent Ramdhanie
A: 

Looks like you are using something that has been replaced. Maybe you are on Java 7?

Here is something that seems to describe this, and where to go to find it's proper replacement.

Francis Upton
+2  A: 

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.

Jesper