Welcome to Srini's blog

Wednesday, May 26, 2010

Java compilation issue with Eclipse settings

Today I got an interesting error while running my sample java appliaction. Error is
Access restriction: The method createJPEGEncoder(OutputStream) from the type JPEGCodec is not accessible due to
restriction on required library C:\Program Files\Java\jdk1.6.0_11\jre\lib\rt.jar

Access restriction: The method getDefaultJPEGEncodeParam(BufferedImage) from the type JPEGImageEncoder is not accessible due to
restriction on required library C:\Program Files\Java\jdk1.6.0_11\jre\lib\rt.jar

Access restriction: The method setJPEGEncodeParam(JPEGEncodeParam) from the type JPEGImageEncoder is not accessible due to
restriction on required library C:\Program Files\Java\jdk1.6.0_11\jre\lib\rt.jar ImageUtil.java.


One of my java application program importing Sun default package "com.sun.image.codec.jpeg.JPEGCodec" which is in C:\Program Files\Java\jdk1.6.0_11\jre\lib\rt.jar.
Upto yesterday its worked for me without any issues except some warning messages, Suddenly today I am unable to run the application and getting above error.
A quick googling Its resolved with small setting modification in eclipse.

Solution :
1. Go to Project properties
2. Expand Java Compiler and Click on Errors/Warnings
3. Click Enable project specific settings.
4. Expand Depricated and restricted API
5. Change forbidden reference(access rules) setting as warning or ignore.

Now try to run the java application.

No comments:

Post a Comment