I'm worried and remembered regularly, so make a note of it. "System property" that defines the amount of memory allocated to Java commands However, depending on the order of description, it is clear whether or not it can be referenced from the class.
environment
$java -version
java version "1.8.0_131"
** Sample class ** The system property "kusatest" is referenced from the class and output.
Test.java
import java.util.*;
public class Test {
public static void main(String[] args) {
System.out.println("start");
System.out.println(System.getProperty("kusatest"));
System.out.println("end");
}
}
** Reference examples **
$ java -Dkusatest=a Test
start
a
end
** Examples that cannot be referenced **
$ java Test -Dkusatest=a
start
null
end
I wrote the class / Jar and wrote the properties later, so it was easy to make a mistake. I forget it every time and waste a few hours, so I want to remember it anymore.
Recommended Posts