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

相关文章
|
关系型数据库 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
4612 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
122 0
Program type already present: org.intellij.lang.annotations.Flow\Program type already present: org.i
custom field further usage - add into UI and report
custom field further usage - add into UI and report
141 0
custom field further usage - add into UI and report
how drop down list description is displayed by UI framework
how drop down list description is displayed by UI framework
how drop down list description is displayed by UI framework
how does gateway framework treat default system flag in customizing
Suppose we have maintain multiple backend system as “default” in customizing:
130 0
how does gateway framework treat default system flag in customizing
CL_ABAP_COMPILER - get ID - double click on local variable
CL_ABAP_COMPILER - get ID - double click on local variable
142 0
CL_ABAP_COMPILER - get ID - double click on local variable
SAP UI5 Opportunity type long description empty issue
Created by Wang, Jerry, last modified on Mar 03, 2016
111 0
SAP UI5 Opportunity type long description empty issue
the code place where the binding is converted to final value displayed in ui
the code place where the binding is converted to final value displayed in ui
114 0
the code place where the binding is converted to final value displayed in ui
|
Android开发 数据格式 XML
Architecture -- Data Binding Library
1). 简介 Data Binding Library是一个支持库,允许在布局文件中绑定数据源。最小支持API为14,gradle插件最小为1.5.0。示例 2).
895 0