0

I am trying to import java project into eclipse (version - 4.8.0), it shows error on import for below API.

com.sun.management.OperatingSystemMXBean

Error Shown is :

Access restriction: The type 'OperatingSystemMXBean' is not API (restriction on required library 'C:\Program Files\Java\jre1.8.0_212\lib\rt.jar')

PFB JDK and JRE versions in command prompt:

C:\Users\apps>javac -version
javac 1.8.0_212

C:\Users\apps>java -version
java version "1.8.0_212"
Java(TM) SE Runtime Environment (build 1.8.0_212-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.212-b10, mixed mode)
Ranjeet
  • 151
  • 6
  • 18
  • 1
    check https://stackoverflow.com/questions/25222811/access-restriction-the-type-application-is-not-api-restriction-on-required-l – BevynQ Jul 10 '20 at 06:26
  • Below work around mentioned as an answer - "I was having the same problem. When I initially created the java project in Eclipse I specified JRE 8. When I went into the project's build path and edited the JRE System Library, the Java 8 execution environment was selected. When I chose to use an "Alernate JRE" (still java 8) it fixed the error for me" – Ranjeet Jul 10 '20 at 07:12

1 Answers1

1

Go to the project's build path and edit the JRE System Library, the Java 8 execution environment was selected. I chose to use an "Alernate JRE" (still java 8) it fixed the error for me.

Ranjeet
  • 151
  • 6
  • 18