2

I was trying to implement the concept of swing using eclipse in jdk 1.8 but when I used the identifier like JButton then an error came :

The type JButton is not accessible due to restriction on required library C:\ProgramFiles
\Java\jre 1.8.0_31\lib\rt.jar

I am a newbie Java programmer.Can someone please help me out with this error?

ram
  • 23
  • 4

1 Answers1

2

Your project settings are wrong. An ancient question can be found here with the same issue (and the correct way to resolve it).

Basically you need to check your project's Build Path to make sure that it's referring to the default JRE and you're not including the Swing classes from somewhere else causing a conflict: Eclipse sees that you're trying to use class JButton from foobar.jar instead of rt.jar and is saying that it's not right.

Community
  • 1
  • 1
Kayaman
  • 67,952
  • 3
  • 69
  • 110