Java System.getProperty() 方法识别的标准键的完整列表是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31022320/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the full list of standard keys recognized by the Java System.getProperty() method?
提问by Gustave
Is there a reference page that lists all the standard property keys that are always accepted by the Java System.getProperty(key)
method?
是否有一个参考页面列出了 JavaSystem.getProperty(key)
方法始终接受的所有标准属性键?
I am not referring to system properties that can be set by the user of the java command (this would be an unlimited list), but to the properties the runtime sets itself (such as java.version
, java.specification.version
, etc).
我不是指的是可以通过java命令的用户设置系统属性(这将是一个无限的列表),但对性能运行时将其自身设置(如java.version
,java.specification.version
等)。
回答by JFK
Maybe also helpful:
也许也有帮助:
Show the effective property values your JVM picks up:
java -XshowSettings:all
显示您的 JVM 选择的有效属性值:
java -XshowSettings:all
回答by Danielson
Like: https://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html? I'd say Oracle will have a list
像:https: //docs.oracle.com/javase/tutorial/essential/environment/sysprop.html?我会说甲骨文会有一个列表
Update (copied from link above):
更新(从上面的链接复制):
"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
A more complete list from https://docs.oracle.com/javase/8/docs/api/java/lang/System.html
来自https://docs.oracle.com/javase/8/docs/api/java/lang/System.html 的更完整列表
java.version Java Runtime Environment version
java.vendor Java Runtime Environment vendor
java.vendor.url Java vendor URL
java.home Java installation directory
java.vm.specification.version Java Virtual Machine specification version
java.vm.specification.vendor Java Virtual Machine specification vendor
java.vm.specification.name Java Virtual Machine specification name
java.vm.version Java Virtual Machine implementation version
java.vm.vendor Java Virtual Machine implementation vendor
java.vm.name Java Virtual Machine implementation name
java.specification.version Java Runtime Environment specification version
java.specification.vendor Java Runtime Environment specification vendor
java.specification.name Java Runtime Environment specification name
java.class.version Java class format version number
java.class.path Java class path
java.library.path List of paths to search when loading libraries
java.io.tmpdir Default temp file path
java.compiler Name of JIT compiler to use
java.ext.dirs Path of extension directory or directories Deprecated. This property, and the mechanism which implements it, may be removed in a future release.
os.name Operating system name
os.arch Operating system architecture
os.version Operating system version
file.separator File separator ("/" on UNIX)
path.separator Path separator (":" on UNIX)
line.separator Line separator ("\n" on UNIX)
user.name User's account name
user.home User's home directory
user.dir User's current working directory
Although some duplicates, I think the former descriptions are more informative than the latter. The latter lists 28 properties, whereas if I print all the properties, my jvm responds with 56, some not listed in the 28 include sun.*
(12), *.awt.*
(3), 7 out of 10 user properties (country.format, country, script, variant, timezone, language, language.format
)
虽然有些重复,但我认为前者的描述比后者提供的信息更多。后者列出了 28 个属性,而如果我打印所有属性,我的 jvm 响应为 56,其中一些未列在 28 中包括sun.*
(12)、*.awt.*
(3)、10 个用户属性中的 7 个 ( country.format, country, script, variant, timezone, language, language.format
)
回答by abel
For a better way of printing the output, you may use the following code. Note that this code is completely functional in the environment and programming language Processing. (Yes, it is Java based)
为了更好地打印输出,您可以使用以下代码。请注意,此代码在环境和编程语言Processing 中完全起作用。(是的,它是基于 Java 的)
String Junk = System.getProperties().toString();
Junk = Junk.replace("}", "").replace("{", "");
String Separated [] = split(Junk, ", ");
for(int S = 0; S < Separated.length; S ++) {
String splitFurther [] = split(Separated [S], "=");
println("Key: " + splitFurther [0] + "\n\tProperty: " + splitFurther [1]);
}
Hope it helps. ;)
希望能帮助到你。;)
回答by CanGu
You can display all properties and their settings on you console using following code
您可以使用以下代码在控制台上显示所有属性及其设置
//Properties inherits form Hashtable and holds the
//Information of what the Propertie is called (key)
//and what the Propertie really is (value)
Properties props = System.getProperties();
//We want to loop through the entrys using the Keyset
Set<object> propKeySet = props.keySet();
for (Object singleKey : propKeySet) {
System.out.println(singleKey += props.getProperty((String) singleKey));
}
You can find an example here http://javacodingnerd.blogspot.de/2017/03/java-how-to-gather-system-properties.html
你可以在这里找到一个例子 http://javacodingnerd.blogspot.de/2017/03/java-how-to-gather-system-properties.html
回答by Johnson Abraham
You can use this code to get the system properties:
您可以使用此代码获取系统属性:
import java.util.Properties;
import java.util.Enumeration;
Properties props = System.getProperties();
Enumeration propNames = props.propertyNames();
for (; propNames.hasMoreElements();) {
String key = propNames.nextElement().toString();
System.out.println(key + " : " + props.getProperty(key));
}
You can also get the environment information from System.getEnv().
您还可以从 System.getEnv() 获取环境信息。