If I set the system property with -D, can I access it from my code?

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?

+4
source share
3 answers

Besides System.getProperty , there is also Integer.getInteger and Boolean.getBoolean if you want to get an integral or boolean value . Boolean.getBoolean

+3
source

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

+1
source

All Articles