Java-System.getProperty()

Java平台使用了一个Poperties对象来维护其自己的配置信息。System泪中包含有一个Properties对象用于描述当前工作环境的配置。系统properties包含了关于当前用户、当前Java运行时版本、文件路径分隔符等信息。

Key Meaning
"file.separator" Character that separates components of a file path. This is "/" on UNIX and "\" on Windows.
"java.class.path" Path used to find directories and JAR archives containing class files. Elements of the class path are separated by a platform-specific character specified in the path.separator property.
"java.home" Installation directory for Java Runtime Environment (JRE)
"java.vendor" JRE vendor name
"java.vendor.url" JRE vendor URL
"java.version" JRE version number
"line.separator" Sequence used by operating system to separate lines in text files
"os.arch" Operating system architecture
"os.name" Operating system name
"os.version" Operating system version
"path.separator" Path separator character used in java.class.path
"user.dir" User working directory
"user.home" User home directory
"user.name" User account name

实际数据:

public static void main(String args[]) {
      System.out.println("java_vendor:" + System.getProperty("java.vendor"));
      System.out.println("java_vendor_url:" + System.getProperty("java.vendor.url"));
      System.out.println("java_home:" + System.getProperty("java.home"));
      System.out.println("java_class_version:" + System.getProperty("java.class.version"));
      System.out.println("java_class_path:" + System.getProperty("java.class.path"));
      System.out.println("os_name:" + System.getProperty("os.name"));
      System.out.println("os_arch:" + System.getProperty("os.arch"));
      System.out.println("os_version:" + System.getProperty("os.version"));
      System.out.println("user_name:" + System.getProperty("user.name"));
      System.out.println("user_home:" + System.getProperty("user.home"));
      System.out.println("user_dir:" + System.getProperty("user.dir"));
      System.out.println("java_vm_specification_version:" + System.getProperty("java.vm.specification.version"));
      System.out.println("java_vm_specification_vendor:" + System.getProperty("java.vm.specification.vendor"));
      System.out.println("java_vm_specification_name:" + System.getProperty("java.vm.specification.name"));
      System.out.println("java_vm_version:" + System.getProperty("java.vm.version"));
      System.out.println("java_vm_vendor:" + System.getProperty("java.vm.vendor"));
      System.out.println("java_vm_name:" + System.getProperty("java.vm.name"));
      System.out.println("java_ext_dirs:" + System.getProperty("java.ext.dirs"));
      System.out.println("file_separator:" + System.getProperty("file.separator"));
      System.out.println("path_separator:" + System.getProperty("path.separator"));
      System.out.println("line_separator:" + System.getProperty("line.separator"));
}

输出:

java_vendor:Oracle Corporation
java_vendor_url:http://java.oracle.com/
java_home:/Library/Java/JavaVirtualMachines/jdk1..0_79.jdk/Contents/Home/jre
java_class_version:51.0
java_class_path:/Users/awp/Documents/otherproject/MyJmeterDemo/bin:/Users/awp/Documents/otherproject/MyJmeterDemo/libs/ApacheJMeter_core.jar:/Users/awp/Documents/otherproject/MyJmeterDemo/libs/ApacheJMeter_java.jar:/Users/awp/Documents/otherproject/MyJmeterDemo/libs/jorphan-.jar:/Users/awp/Documents/otherproject/MyJmeterDemo/libs/avalon-framework-api-.jar:/Users/awp/Documents/otherproject/MyJmeterDemo/libs/ApacheJMeter_http.jar:/Users/awp/Documents/otherproject/MyJmeterDemo/libs/oro-.jar:/Users/awp/Documents/otherproject/MyJmeterDemo/libs/commons-io-.jar:/Users/awp/Documents/otherproject/MyJmeterDemo/libs/xstream--SNAPSHOT.jar
os_name:Mac OS X
os_arch:x86_64
os_version:
user_name:awp
user_home:/Users/awp
user_dir:/Users/awp/Documents/otherproject/MyJmeterDemo
java_vm_specification_version:1.7
java_vm_specification_vendor:Oracle Corporation
java_vm_specification_name:Java Virtual Machine Specification
java_vm_version:24.79-b02
java_vm_vendor:Oracle Corporation
java_vm_name:Java HotSpot(TM) -Bit Server VM
java_ext_dirs:/Users/awp/Library/Java/Extensions:/Library/Java/JavaVirtualMachines/jdk1..0_79.jdk/Contents/Home/jre/lib/ext:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java
file_separator:/
path_separator::
line_separator:
上一篇:vue学习目录 vue初识 this指向问题 vue组件传值 过滤器 钩子函数 路由 全家桶 脚手架 vuecli element-ui axios bus


下一篇:按要求编写Java程序: (1)编写一个接口:InterfaceA,只含有一个方法int method(int n); (2)编写一个类:ClassA来实现接口InterfaceA,实现int method(int n)接口方 法时,要求计算1到n的和; (3)编写另一个类:ClassB来实现接口InterfaceA,实现int method(int n)接口 方法时,要求计算n的阶乘(n!);