Com.sun.management.OperatingSystemMXBean Mxbean = (Com.sun.management.OperatingSystemMXBean) Managementfactory.getoperatingsystemmxbean (); SYSTEM.OUT.PRINTLN ("Operating system:" +mxbean.getname ()); System.out.println ("Number of CPUs:" + mxbean.getavailableprocessors ()); SYSTEM.OUT.PRINTLN ("Virtual Memory:" +mxbean.getcommittedvirtualmemorysize ()/1024 + "KB"); SYSTEM.OUT.PRINTLN ("Available Physical Memory:" +mxbean.getfreephysicalmemorysize ()/1024x768 + "KB"); System.out.println ("Free Swap Space Size:" +mxbean.getfreeswapspacesize ()/1024x768 + "KB"); System.out.println ("Process CPU Time:" +mxbean.getprocesscputime ()); SYSTEM.OUT.PRINTLN ("Total Physical memory Size:" +mxbean.gettotalphysicalmemorysize ()/1024x768 + "KB"); System.out.println ("Total Swap Space Size:" +mxbean.gettotalswapspacesize ()/1024x768 + "KB");
- Operatingsystemmxbean
This class provides simple information about the operating system, such as the schema name, current number of CPUs, recent system load, and so on.
- Runtimemxbean
Run-time information includes the name of the current virtual machine, provider, version number, and Classpath, Bootclasspath, and system parameters, among others.
2008-04-29
Java: Read System Information