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?
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 defaultJRE
and you're not including the Swing classes from somewhere else causing a conflict: Eclipse sees that you're trying to use classJButton
fromfoobar.jar
instead ofrt.jar
and is saying that it's not right.