Java-System.getProperty()
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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.7.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-2.9.jar:/Users/awp/Documents/otherproject/MyJmeterDemo/libs/logkit-1.2.2.jar:/Users/awp/Documents/otherproject/MyJmeterDemo/libs/avalon-framework-api-4.3.1.jar:/Users/awp/Documents/otherproject/MyJmeterDemo/libs/ApacheJMeter_http.jar:/Users/awp/Documents/otherproject/MyJmeterDemo/libs/oro-2.0.8.jar:/Users/awp/Documents/otherproject/MyJmeterDemo/libs/commons-io-2.4.jar:/Users/awp/Documents/otherproject/MyJmeterDemo/libs/commons-lang3-3.3.2.jar:/Users/awp/Documents/otherproject/MyJmeterDemo/libs/xstream-1.5.0-SNAPSHOT.jar os_name:Mac OS X os_arch:x86_64 os_version:10.10.5 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) 64-Bit Server VM java_ext_dirs:/Users/awp/Library/Java/Extensions:/Library/Java/JavaVirtualMachines/jdk1.7.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:
以上是关于Java-System.getProperty()的主要内容,如果未能解决你的问题,请参考以下文章