public class SystemTest
{
public static void main(String args[])
{
String str;
//java运行时环境版本
str = System.getProperty("java.version");
System.out.println("java.version: " + str);
//java虚拟机实现的版本
str = System.getProperty("java.vm.version");
System.out.println("java.vm.version: " + str);
//java类的路径
str = System.getProperty("java.class.path");
System.out.println("java.class.path: " + str);
//操作系统的版本
str = System.getProperty("os.version");
System.out.println("os.version: " + str);
//用户名
str = System.getProperty("user.name");
System.out.println("user.name: " + str);
//用户路径
str = System.getProperty("user.dir");
System.out.println("user.dir: " + str);
//用户HOME路径
str = System.getProperty("user.home");
System.out.println("user.home: " + str);
}
}
程序的运行结果为:
java.version: 1.4.1_02
java.vm.version: 1.4.1_02-b06
java.class.path: D:\JBuilder9\jdk1.4\lib;D:\;.;
os.version: 5.0
user.name: administrator
user.dir: E:\Java\chapt5
user.home: C:\Documents and Settings\Administrator.ZXB |
|