Wondering what happens when I declare a custom property in java using -D command. I came to know that other system properties are not stored, instead generated by JVM. So what will happen to the property that I created? Can I use it next time while I compile the code without declaring again?
example: java -D"custom_key"="custom_value" some_class
System properties are evaluated at runtime only not at compilation time.
public class SysProp {
public static void main(String[] args) {
System.out.println(System.getProperty("foo", "<foo not set>"));
}
}
java SysProp
Output: <foo not set>
java -Dfoo=bar
Output: bar
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.