• Java:读取系统信息


    com.sun.management.OperatingSystemMXBean mxbean =
    
          (com.sun.management.OperatingSystemMXBean)
          ManagementFactory.getOperatingSystemMXBean();
        
         System.out.println("操作系统: "+mxbean.getName());
         System.out.println("CPU数量:" + mxbean.getAvailableProcessors());
         System.out.println("虚拟内存:"+mxbean.getCommittedVirtualMemorySize() /1024 + "KB");
         System.out.println("可用物理内存:"+mxbean.getFreePhysicalMemorySize() / 1024 + "KB");
         System.out.println("Free Swap Space Size :"+mxbean.getFreeSwapSpaceSize() / 1024 + "KB");
         System.out.println("Process CPU Time : "+mxbean.getProcessCpuTime());
         System.out.println("总物理内存大小:"+mxbean.getTotalPhysicalMemorySize() / 1024 + "KB");
         System.out.println("Total Swap Space Size:"+mxbean.getTotalSwapSpaceSize() / 1024 + "KB");
    

      

    • OperatingSystemMXBean

      该类提供的是操作系统的简单信息,如构架名称、当前 CPU 数、最近系统负载等。

    • RuntimeMXBean

      运行时信息包括当前虚拟机的名称、提供商、版本号,以及 classpath、bootclasspath 和系统参数等等。

    2008-04-29

  • 相关阅读:
    python的Collections 模块
    python模块
    python类
    python异常
    python文件处理
    python函数
    python字符串
    python数据结构
    python循环
    下载Google Play外国区APP技巧
  • 原文地址:https://www.cnblogs.com/personnel/p/4582923.html
Copyright © 2020-2023  润新知