The type sun.management.ManagementFactory is not visible

简介: Eclipse默认将这些受访问限制的API设成了Error。解决方法:只要将Windows---Preferences---Java--Complicer---Errors/Warings里面的Deprecated and restricted API中的Forbidden references(access rules) 选为Waring就可以编译过了   今天在JDK1.7中引入sun.management.ManagementFactory,会报错。

Eclipse默认将这些受访问限制的API设成了Error。
解决方法:
只要将Windows---Preferences---Java--Complicer---Errors/Warings里面的Deprecated and restricted API中的Forbidden references(access rules) 选为Waring就可以编译过了

 

今天在JDK1.7中引入sun.management.ManagementFactory,会报错。之前在JDK1.6中引入并无错,刚开始怀疑是否是JDK版本升级了,此方法类过期。接着打开JDK1.7中的rt.jar中,发现是有此类的。

     上网查阅,有人也出现过此问题,不过似乎不是因为JDK版本的问题,他的解决办法是更改此类的引用路径,改为java.lang.management.ManagementFactory,我试了下,确实可以的,不过至于JDK1.7版本中,为什么无法引用sun.management.ManagementFactory,我始终还不明白(如有哪位了解为什么,还望可以指点)。后来我把JDK1.7卸载掉了,装了1.6版本的,对于引用sun.management.ManagementFactory、java.lang.management.ManagementFactory均是可以的。

 

由于本人知识有限,暂时还不了解rt.jar中sun和java.lang中的类有啥区别,为什么都会有ManagementFactory方法类?

http://tim-fly.iteye.com/blog/1297572

http://bbs.csdn.net/topics/390083947

相关文章
|
5月前
|
Java Android开发
Invoke-customs are only supported starting with Android,Static interface methods are only supported
Invoke-customs are only supported starting with Android,Static interface methods are only supported
53 2
DT Slate Brush Browser Plug -in description
DT Slate Brush Browser Plug -in description
77 0
|
关系型数据库 MySQL Java
Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' property manually
Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' property manually
4670 1
Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' property manually
|
Kotlin
Program type already present: org.intellij.lang.annotations.Flow\Program type already present: org.i
Program type already present: org.intellij.lang.annotations.Flow\Program type already present: org.i
132 0
Program type already present: org.intellij.lang.annotations.Flow\Program type already present: org.i
|
云计算
Google Earth Engine(GEE)——Error: Exported bands must have compatible data types; found inconsistent
Google Earth Engine(GEE)——Error: Exported bands must have compatible data types; found inconsistent
529 0
Google Earth Engine(GEE)——Error: Exported bands must have compatible data types; found inconsistent