java获取系统信息

时间:2022-01-19 17:24:08
public class SystemInfo {

	public static void main(String[] args) {
//系统属性
Properties prop = System.getProperties(); System.out.println(prop.getProperty("os.name")); // 操作系统名称 Windows 7
System.out.println(prop.getProperty("os.version")); //操作系统版本6.1
System.out.println(prop.getProperty("os.arch")); //操作系统架构 当前x86
System.out.println(prop.getProperty("java.version")); //Java版本1.6.0_17
System.out.println(prop.getProperty("java.vendor")); // jdk厂商Sun Microsystems Inc.
System.out.println(prop.getProperty("java.specification.version")); //Java运行时环境版本1.6
System.out.println(prop.getProperty("java.specification.name")); //Java运行时环境Java Platform API Specification
System.out.println(prop.getProperty("java.vm.version")); //Java虚拟机版本14.3-b01
System.out.println(prop.getProperty("java.vm.name"));// Java虚拟机Java HotSpot(TM) Client VM
System.out.println(prop.getProperty("user.dir"));//用户临时目录D:\workspace01\ssi System.out.println(Runtime.getRuntime().maxMemory()/1024/1024 + "" ); //最大内存 63M
System.out.println(Runtime.getRuntime().totalMemory()/1024/1024 + "" ); //可用内存 4M
System.out.println(Runtime.getRuntime().freeMemory()/1024/1024 + "" ); //剩余内存 4M }
}