无法在java类中导入org.sun.management.OperatingSystemMXBean? [英] unable to import org.sun.management.OperatingSystemMXBean in java class?

查看:293
本文介绍了无法在java类中导入org.sun.management.OperatingSystemMXBean?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JRE系统库中看到 org.sun.management ,但我无法在我的eclipse中导入。允许它的任何原因。甚至maven编译失败



这里是截图。





我使用 Java 8。



我正在尝试这样做:

  if(operatingSystemBean instanceof com.sun.mananagement.OperatingSystemMXBean){


})


解决方案

Eclipse阻止您访问Sun的专有实现细节,因为它无法通过其他JVM移植。



您可以更改项目设置,以便Eclipse将此类问题视为警告而不是错误。



我在Mac上最新Eclipse的步骤:



项目 - 属性
- > Java编译器
- >错误/警告
- >启用项目特定设置
- >不推荐使用和限制API
- >禁止参考:警告


I see the org.sun.management in JRE System library but I am unable to import in my eclipse. Any reasons why it is allowed. even maven compilation fails

here are the screenshots.

I am using Java 8.

I am trying to do this:

if (operatingSystemBean  instanceof com.sun.mananagement.OperatingSystemMXBean) {


        })

解决方案

Eclipse is preventing you from accessing Sun's proprietary implementation details as that won't be portable across other JVMs.

You can change the project settings so that Eclipse will treat that type of issue as a warning rather than as an error.

My steps for Latest Eclipse on Mac:

Project - Properties -> Java Compiler -> Errors / Warnings -> Enable Project specific settings -> Deprecated and restricted API -> Forbidden reference : Warning

这篇关于无法在java类中导入org.sun.management.OperatingSystemMXBean?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆