I would like to be able to set the property on the JVM using the -D switch. If I do, can I access it from my code? If so, how?
-D
Use System.getProperty("mykey");
System.getProperty("mykey");
Besides System.getProperty , there is also Integer.getInteger and Boolean.getBoolean if you want to get an integral or boolean value . Boolean.getBoolean
System.getProperty
Integer.getInteger
Boolean.getBoolean
and as a bonus:
System.setProperty("yourkey",yourValue); //works very well too
allows you to make sure that the property is set if you want to check things