Eclipse Compilation error: [function/type] is not accessible due to restriction on required library … rt.jar

Problem : Eclipse gives the error – “[function/type] is not accessible due to restriction on required library … rt.jar” when building a project.

Reason: Project  classpath (in the build path) is refers to JRE in place of the JDK in which the Project is configured to work with.

Fix:  Go to Java Build Path > Libraries, choose JRE System Library, click Edit button. From the dialog choose Alternate JRE and choose the required JDK.

Sreekumar Kj
Sreekumar (KJ) has been a hobby programmer from school days. Codemarvels is his personal blog from the year 2010, where he writes about technology, philosophy, society and a bit about physics. He now runs a conversational AI company - DheeYantra - focusing his efforts to help businesses improve operational efficiency using digital employees powered by AI.