What is the full list of standard keys recognized

2019-02-04 12:05发布

Is there a reference page that lists all the standard property keys that are always accepted by the Java System.getProperty(key) method?

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).

5条回答
Animai°情兽
2楼-- · 2019-02-04 12:36

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)

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. ;)

查看更多
做个烂人
3楼-- · 2019-02-04 12:47

Like: https://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html ? I'd say Oracle will have a list

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

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)

查看更多
仙女界的扛把子
4楼-- · 2019-02-04 12:47

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

查看更多
够拽才男人
5楼-- · 2019-02-04 13:00

Maybe also helpful:

  • Show the effective property values your JVM picks up:

    java -XshowSettings:all
    
查看更多
太酷不给撩
6楼-- · 2019-02-04 13:03

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().

查看更多
登录 后发表回答