Eclipse 3.5.1 Compiler error: the OutputFormat type is not available due to a restriction on the required library. / Rt.jar

This mistake is strange, and I cannot fully understand it. I installed EclipseRCP 3.5.1, Update Java SE 1.6 16 and upgrade to SWT 3.5. I created a new project, installed dependencies and tried to compile. When trying to import, use the following:

import com.sun.org.apache.xml.internal.serialize.OutputFormat; import com.sun.org.apache.xml.internal.serialize.XMLSerializer; 

I get an error:

 Access restriction: The type XMLSerializer is not accessible due to restriction on required library C:\Program Files\Java\jre6\lib\rt.jar. 

I already have google, read a few answers here ... and the problem is still there. The funny thing is that if I use the previous EclipseRCP (Version: 3.4.2), this problem never occurs. Version 3.4.2 uses the same version of the JRE, and I just tested the SWT version. Works great. I assume the problem is with some plugin of the new IDE. Any ideas?

PS I found this article. But I do not like or want to change the code if I do not need it. First, the source of the problem, and a solution will follow.

+6
java restriction
source share
3 answers

The default configuration of the Eclipse compiler is too restrictive. You can weaken it by opening Java โ†’ Compiler โ†’ Errors / Warnings preferences and in the "Deprecated and Restricted API" section change the setting "Forbidden Link (Access Rules)" from error to warning or ignore.

However, if you really want to use the classes in the com.sun.-package, since you are not guaranteed that they will be available in the virtual machine from another vendor or the new VM from Sun.

+10
source share

Just notice for those who are faced with a similar problem and cannot get Eclipse to work (for example, I am now): check that the "Forbidden link" is not set to "Error" in the project -special settings.

+1
source share

I am posting this old thread for reference only to anyone who encounters this in the future.

I had the same problem, but it was caused by the fact that I had a compiler compliance level of 1.5 when using the 1.6 compiler. All the advantages that are included in 1.6 (for example, javax.activation and some of the xml features mentioned above) will be "limited" by the 1.6 compiler if the compliance level is set below 1.6. I just needed to add the appropriate libraries (e.g. activ.jar) to get rid of the problem in my case.

+1
source share

All Articles