Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'd like to be able to set a property on the JVM using the -D switch. If I do that, can I access it from my code? If yes, how?

like image 520
Geo Avatar asked Dec 05 '22 03:12

Geo


2 Answers

Use System.getProperty("mykey");

like image 78
McDowell Avatar answered Jan 18 '23 23:01

McDowell


Apart from System.getProperty, there's also Integer.getInteger and Boolean.getBoolean, if you want to get an integral or boolean value instead. :-)

like image 37
Chris Jester-Young Avatar answered Jan 19 '23 00:01

Chris Jester-Young