Can command-line set Java system properties be distinguished from the defaults? -
is there way distinguish java system property has been set command line using -d
option system property got same value default?
e.g., program
class test { public static void main(string[] args) { system.out.println(system.getproperty("user.home")); } }
prints
/home/uckelman
for me regardless of whether run
java test
or
java -duser.home=/home/uckelman test
is there jdk provides test distinguish these 2 situations?
one way command line arguments used start jvm , check returned list if given system property set or not.
runtimemxbean mx = managementfactory.getruntimemxbean(); system.out.println("command line args:\n" + mx.getinputarguments());
Comments
Post a Comment