Error Access Restriction: The type is not accessible

Asked

Viewed 197 times

1

I’m trying to develop a simple java screen using JFrame but in my eclipse is showing a message on JFrame.

Access Restriction: The Construction Jframe(String) is not accessible due to Restriction on required library usr/lib/jvm/java-8-openjdk-amd64/jre/lib/rt.jar

Access Restriction: The type Jframe is not accessible due to Restriction on required library usr/lib/jvm/java-8-openjdk-amd64/jre/lib/rt.jar

My eclipse is on Linux Mint 18.3 (Sylvia)

My code:

package view;
import javax.swing.*;
public class TelaInicial {


    private void construirJanela(){

        JFrame janela = new JFrame("Janela");
        janela.setVisible(true);

    }

}

My java is like this:

carlos@carlos /usr/lib/jvm $ java -version
openjdk version "1.8.0_162"
OpenJDK Runtime Environment (build 1.8.0_162-8u162-b12-0ubuntu0.16.04.2-b12)
OpenJDK 64-Bit Server VM (build 25.162-b12, mixed mode)
  • You made sure you have JRE on the same architecture as the eclipse?

  • installed by apt-get install eclipse

  • Try this: https://stackoverflow.com/a/2174607/5524514

  • It worked! Thank you very much! You can add reply

  • You can answer, since the solution was not mine, but Soen’s :D

1 answer

1


In accordance with this answer in Soen, you can try the following:

  • Right-click on the project and select Properties;
  • Go to "Java Build Path" and remove the lib "JRE System Library";
  • Reset it by clicking on "Add Library".

The probable reason for this error must be class conflicts with similar names in different libraries added to the project. Resetting the system jar, you reorder this jar to the top of the list to be consulted when importing a class with a similar name.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.