你去看看Runtime,System这两个类的文档,相信你能找到你要的东西

解决方案 »

  1.   

    sun的标准包中只有Runtime的 freeMemory,maxMemory,totalMemory方法能返回你要的东西,但是他们返回的都是虚拟机的内存使用信息,对于cpu的信息就没办法了,如
    totalMemory() 
              Returns the total amount of memory in the Java virtual machine.
              返回系统分配给虚拟机的总内存数量maxMemory() 
              Returns the maximum amount of memory that the Java virtual machine will attempt to use.
              返回虚拟机将可以调用的最大内存数量freeMemory() 
              Returns the amount of free memory in the Java Virtual Machine.
              即返回当前虚拟机空闲的内存数量所以真正要得到你要的东西只有调用系统api才行
      

  2.   

    使用命令
    java -Xrunhprof:cpu=sample,file=prof.txt <class文件名〉
    java -Xrunhprof:help得到帮助
      

  3.   

    我就是想问有没有第三方的函数库可以在java 程序中调用,我知道关于网络资源的检测可以用netsnmpj函数库,但是好象比较复杂,有没有简单一点的??